-
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.
Merge pull request #118 from AArnott/xunitv3
Target xUnit v3 for our v2 release
- Loading branch information
Showing
67 changed files
with
1,427 additions
and
963 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
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 |
---|---|---|
@@ -1,41 +1,16 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// 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) | ||
/// <inheritdoc/> | ||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) | ||
{ | ||
this.diagnosticMessageSink = diagnosticMessageSink; | ||
} | ||
|
||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) | ||
{ | ||
if (testMethod is null) | ||
{ | ||
throw new ArgumentNullException(nameof(testMethod)); | ||
} | ||
|
||
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."); | ||
} | ||
|
||
UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); | ||
return new UITestCase(UITestCase.SyncContextType.Cocoa, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings); | ||
return CocoaUtilities.CreateTestCaseForFact(discoveryOptions, testMethod, 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
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,53 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// Licensed under the Ms-PL license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Xunit.Sdk; | ||
|
||
internal static class CocoaUtilities | ||
{ | ||
private const UITestCase.SyncContextType ContextType = UITestCase.SyncContextType.Cocoa; | ||
private const string? SkipReason = null; | ||
|
||
internal static IXunitTestCase CreateTestCaseForFact( | ||
ITestFrameworkDiscoveryOptions discoveryOptions, | ||
IXunitTestMethod testMethod, | ||
IFactAttribute factAttribute) | ||
{ | ||
return Utilities.CreateTestCaseForFact( | ||
ContextType, | ||
SkipReason, | ||
discoveryOptions, | ||
testMethod, | ||
factAttribute); | ||
} | ||
|
||
internal static IXunitTestCase CreateTestCaseForDataRow( | ||
ITestFrameworkDiscoveryOptions discoveryOptions, | ||
IXunitTestMethod testMethod, | ||
ITheoryAttribute theoryAttribute, | ||
ITheoryDataRow dataRow, | ||
object?[] testMethodArguments) | ||
{ | ||
return Utilities.CreateTestCaseForDataRow( | ||
ContextType, | ||
SkipReason, | ||
discoveryOptions, | ||
testMethod, | ||
theoryAttribute, | ||
dataRow, | ||
testMethodArguments); | ||
} | ||
|
||
internal static IXunitTestCase CreateTestCaseForTheory( | ||
ITestFrameworkDiscoveryOptions discoveryOptions, | ||
IXunitTestMethod testMethod, | ||
ITheoryAttribute theoryAttribute) | ||
{ | ||
return Utilities.CreateTestCaseForTheory( | ||
ContextType, | ||
SkipReason, | ||
discoveryOptions, | ||
testMethod, | ||
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
39 changes: 7 additions & 32 deletions
39
src/Xunit.StaFact/Sdk.WindowsDesktop/WinFormsFactDiscoverer.cs
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 |
---|---|---|
@@ -1,44 +1,19 @@ | ||
// Copyright (c) Andrew Arnott. All rights reserved. | ||
// 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; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Xunit.Sdk; | ||
|
||
/// <summary> | ||
/// The discovery class for <see cref="WinFormsFactAttribute"/>. | ||
/// </summary> | ||
public class WinFormsFactDiscoverer : FactDiscoverer | ||
{ | ||
private readonly IMessageSink diagnosticMessageSink; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WinFormsFactDiscoverer"/> class. | ||
/// </summary> | ||
/// <param name="diagnosticMessageSink">The diagnostic message sink.</param> | ||
public WinFormsFactDiscoverer(IMessageSink diagnosticMessageSink) | ||
: base(diagnosticMessageSink) | ||
/// <inheritdoc/> | ||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, IXunitTestMethod testMethod, IFactAttribute factAttribute) | ||
{ | ||
this.diagnosticMessageSink = diagnosticMessageSink; | ||
} | ||
|
||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) | ||
{ | ||
if (testMethod is null) | ||
{ | ||
throw new ArgumentNullException(nameof(testMethod)); | ||
} | ||
|
||
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."); | ||
} | ||
|
||
UISettingsAttribute settings = UIFactDiscoverer.GetSettings(testMethod); | ||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) | ||
? new UITestCase(UITestCase.SyncContextType.WinForms, this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, testMethodArguments: null, settings) | ||
: new XunitSkippedDataRowTestCase(this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, "WinForms only exists on Windows."); | ||
return WinFormsUtilities.CreateTestCaseForFact( | ||
discoveryOptions, | ||
testMethod, | ||
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
Oops, something went wrong.