-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cocoa fact attribute and related unit tests (#68)
Co-authored-by: Sandy Armstrong <[email protected]> Co-authored-by: Andrew Arnott <[email protected]>
- Loading branch information
1 parent
8d8e639
commit f3d5569
Showing
24 changed files
with
594 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -349,3 +349,6 @@ MigrationBackup/ | |
|
||
# dotnet tool local install directory | ||
.store/ | ||
|
||
# File built by MacOS | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. | ||
|
||
using Xunit.Sdk; | ||
|
||
namespace Xunit; | ||
|
||
/// <summary> | ||
/// Identifies an xunit test that starts on with a <see cref="System.Threading.SynchronizationContext"/> | ||
/// running on <see cref="Foundation.NSRunLoop.Main"/>. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaFactDiscoverer", ThisAssembly.AssemblyName)] | ||
public class CocoaFactAttribute : FactAttribute | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. | ||
|
||
using Xunit.Sdk; | ||
|
||
namespace Xunit; | ||
|
||
/// <summary> | ||
/// Identifies an xunit theory that starts on with a <see cref="System.Threading.SynchronizationContext"/> | ||
/// running on <see cref="Foundation.NSRunLoop.Main"/>. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] | ||
[XunitTestCaseDiscoverer("Xunit.Sdk.CocoaTheoryDiscoverer", ThisAssembly.AssemblyName)] | ||
public class CocoaTheoryAttribute : TheoryAttribute | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace Xunit.Sdk; | ||
|
||
/// <summary> | ||
/// The discovery class for <see cref="CocoaFactDiscoverer"/>. | ||
/// </summary> | ||
public class CocoaFactDiscoverer : FactDiscoverer | ||
{ | ||
private readonly IMessageSink diagnosticMessageSink; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CocoaFactDiscoverer"/> class. | ||
/// </summary> | ||
/// <param name="diagnosticMessageSink">The diagnostic message sink.</param> | ||
public CocoaFactDiscoverer(IMessageSink diagnosticMessageSink) | ||
: base(diagnosticMessageSink) | ||
{ | ||
this.diagnosticMessageSink = diagnosticMessageSink; | ||
} | ||
|
||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) | ||
{ | ||
if (testMethod.Method.ReturnType.Name == "System.Void" && | ||
testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) | ||
{ | ||
return new ExecutionErrorTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod, "Async void methods are not supported."); | ||
} | ||
|
||
return new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod); | ||
} | ||
} |
Oops, something went wrong.