-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added common extended
Fact
and Theory
attributes to `Microsoft.Do…
…tNet.XUnitExtensions`
- Loading branch information
1 parent
7ed56fa
commit 1511d34
Showing
17 changed files
with
351 additions
and
47 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
30 changes: 0 additions & 30 deletions
30
src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/TestHelper.cs
This file was deleted.
Oops, something went wrong.
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
16 changes: 0 additions & 16 deletions
16
src/Microsoft.DotNet.NuGetRepack/tests/TestHelpers/SkipIfNotWindows.cs
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/DotNetOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on .NET (.NET Core). | ||
/// </summary> | ||
public class DotNetOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DotNetOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public DotNetOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (!DiscovererHelpers.IsRunningOnNetCoreApp) | ||
{ | ||
this.Skip = "This test only runs on .NET.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/DotNetOnlyTheoryAttribute.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on .NET (.NET Core). | ||
/// </summary> | ||
public class DotNetOnlyTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DotNetOnlyTheoryAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public DotNetOnlyTheoryAttribute(string? additionalMessage = null) | ||
{ | ||
if (!DiscovererHelpers.IsRunningOnNetCoreApp) | ||
{ | ||
this.Skip = "This test only runs on .NET.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/LinuxOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Linux. | ||
/// </summary> | ||
public class LinuxOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="LinuxOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public LinuxOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
this.Skip = "This test requires Linux to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/LinuxOnlyTheoryAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Windows. | ||
/// </summary> | ||
public class LinuxOnlyTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="LinuxOnlyTheoryAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public LinuxOnlyTheoryAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
this.Skip = "This test requires Linux to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/OsxOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on OSX. | ||
/// </summary> | ||
public class OsxOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="OsxOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public OsxOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
{ | ||
this.Skip = "This test requires OSX to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/OsxOnlyTheoryAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on OSX. | ||
/// </summary> | ||
public class OsxOnlyTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="OsxOnlyTheoryAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public OsxOnlyTheoryAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) | ||
{ | ||
this.Skip = "This test requires OSX to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/UnixOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Unix (Linux, OSX platforms). | ||
/// </summary> | ||
public class UnixOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UnixOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public UnixOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
this.Skip = "This test requires Unix to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/UnixOnlyTheoryAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Unix (Linux, OSX platforms). | ||
/// </summary> | ||
public class UnixOnlyTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UnixOnlyTheoryAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public UnixOnlyTheoryAttribute(string? additionalMessage = null) | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
this.Skip = "This test requires Unix to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/WindowsFullFrameworkOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Windows on .NET Framework. | ||
/// </summary> | ||
public class WindowsFullFrameworkOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WindowsFullFrameworkOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public WindowsFullFrameworkOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
this.Skip = "This test only runs on Windows on .NET Framework.".AppendAdditionalMessage(additionalMessage); | ||
return; | ||
} | ||
if (!DiscovererHelpers.IsRunningOnNetFramework) | ||
{ | ||
this.Skip = "This test only runs on .NET Framework.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...icrosoft.DotNet.XUnitExtensions/src/Attributes/WindowsFullFrameworkOnlyTheoryAttribute.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Windows on full .NET Framework. | ||
/// </summary> | ||
public class WindowsFullFrameworkOnlyTheoryAttribute : TheoryAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WindowsFullFrameworkOnlyTheoryAttribute"/> class. | ||
/// Creates the attribute. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public WindowsFullFrameworkOnlyTheoryAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
this.Skip = "This test only runs on Windows on full framework.".AppendAdditionalMessage(additionalMessage); | ||
return; | ||
} | ||
if (!DiscovererHelpers.IsRunningOnNetFramework) | ||
{ | ||
this.Skip = "This test only runs on full framework.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Microsoft.DotNet.XUnitExtensions/src/Attributes/WindowsOnlyFactAttribute.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Runtime.InteropServices; | ||
using Microsoft.DotNet.XUnitExtensions; | ||
|
||
namespace Xunit | ||
{ | ||
/// <summary> | ||
/// This test should be run only on Windows. | ||
/// </summary> | ||
public class WindowsOnlyFactAttribute : FactAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="WindowsOnlyFactAttribute"/> class. | ||
/// </summary> | ||
/// <param name="additionalMessage">The additional message that is appended to skip reason, when test is skipped.</param> | ||
public WindowsOnlyFactAttribute(string? additionalMessage = null) | ||
{ | ||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
this.Skip = "This test requires Windows to run.".AppendAdditionalMessage(additionalMessage); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.