Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<PackageVersion Include="MinVer" Version="5.0.0" />
<PackageVersion Include="Moq" Version="4.18.4" />
<PackageVersion Include="morelinq" Version="4.4.0" />
<PackageVersion Include="MSTest.TestFramework" Version="3.11.0" />
<PackageVersion Include="MSTest.Analyzers" Version="3.11.0" />
<PackageVersion Include="MSTest.TestAdapter" Version="3.11.0" />
<PackageVersion Include="MSTest.TestFramework" Version="4.0.1" />
<PackageVersion Include="MSTest.Analyzers" Version="4.0.1" />
<PackageVersion Include="MSTest.TestAdapter" Version="4.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Newtonsoft.Json.Schema" Version="3.0.16" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,17 @@ public void ConstructorTest_NameVersion()
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MSTEST0006:Avoid '[ExpectedException]'", Justification = "Single-line test case")]
public void ConstructorTest_NameVersion_NullVersion()
{
var goComponent = new GoComponent(TestName, null);
var action = () => new GoComponent(TestName, null);
action.Should().ThrowExactly<ArgumentNullException>();
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MSTEST0006:Avoid '[ExpectedException]'", Justification = "Single-line test case")]
public void ConstructorTest_NameVersion_NullName()
{
var goComponent = new GoComponent(null, TestVersion);
var action = () => new GoComponent(null, TestVersion);
action.Should().ThrowExactly<ArgumentNullException>();
}

[TestMethod]
Expand All @@ -56,27 +54,24 @@ public void ConstructorTest_NameVersionHash()
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MSTEST0006:Avoid '[ExpectedException]'", Justification = "Single-line test case")]
public void ConstructorTest_NameVersionHash_NullVersion()
{
var goComponent = new GoComponent(TestName, null, TestHash);
var action = () => new GoComponent(TestName, null, TestHash);
action.Should().ThrowExactly<ArgumentNullException>();
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MSTEST0006:Avoid '[ExpectedException]'", Justification = "Single-line test case")]
public void ConstructorTest_NameVersionHash_NullName()
{
var goComponent = new GoComponent(null, TestVersion, TestHash);
var action = () => new GoComponent(null, TestVersion, TestHash);
action.Should().ThrowExactly<ArgumentNullException>();
}

[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "MSTEST0006:Avoid '[ExpectedException]'", Justification = "Single-line test case")]
public void ConstructorTest_NameVersionHash_NullHash()
{
var goComponent = new GoComponent(TestName, TestVersion, null);
var action = () => new GoComponent(TestName, TestVersion, null);
action.Should().ThrowExactly<ArgumentNullException>();
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
namespace Microsoft.ComponentDetection.TestsUtilities;

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

public sealed class SkipTestIfNotWindowsAttribute : TestMethodAttribute
{
public override TestResult[] Execute(ITestMethod testMethod)
public SkipTestIfNotWindowsAttribute([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
: base(callerFilePath, callerLineNumber)
{
this.CallerFilePath = callerFilePath;
this.CallerLineNumber = callerLineNumber;
}

public string CallerFilePath { get; }

public int CallerLineNumber { get; }

public override Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return
[
return Task.FromResult<TestResult[]>([
new TestResult
{
Outcome = UnitTestOutcome.Inconclusive,
TestFailureException = new AssertInconclusiveException($"Skipped on {RuntimeInformation.OSDescription}."),
},
];
]);
}

return base.Execute(testMethod);
return base.ExecuteAsync(testMethod);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
namespace Microsoft.ComponentDetection.TestsUtilities;

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

public sealed class SkipTestOnWindowsAttribute : TestMethodAttribute
{
public override TestResult[] Execute(ITestMethod testMethod)
public SkipTestOnWindowsAttribute([CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
: base(callerFilePath, callerLineNumber)
{
this.CallerFilePath = callerFilePath;
this.CallerLineNumber = callerLineNumber;
}

public string CallerFilePath { get; }

public int CallerLineNumber { get; }

public override Task<TestResult[]> ExecuteAsync(ITestMethod testMethod)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return
[
return Task.FromResult<TestResult[]>([
new TestResult
{
Outcome = UnitTestOutcome.Inconclusive,
TestFailureException = new AssertInconclusiveException("Skipped on Windows."),
},
];
]);
}

return base.Execute(testMethod);
return base.ExecuteAsync(testMethod);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]
Loading