Skip to content

Commit e1d8e80

Browse files
committed
Convert PlatformServices tests to use new test framework
1 parent f1af440 commit e1d8e80

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1052
-1729
lines changed

src/Adapter/PlatformServices/Constants.cs

-5
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ internal class Constants
1919

2020
public const string TargetFrameworkName = "TargetFrameworkName";
2121

22-
/// <summary>
23-
/// Constants for MSTest in Portable Mode
24-
/// </summary>
25-
public const string PortableVsTestLocation = "PortableVsTestLocation";
26-
2722
public const string PublicAssemblies = "PublicAssemblies";
2823

2924
public const string PrivateAssemblies = "PrivateAssemblies";

test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Deployment/ns10DeploymentItemTests.cs

+13-31
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,90 @@
33

44
namespace MSTestAdapter.PlatformServices.Tests.Deployment;
55

6-
#if NETCOREAPP
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
#else
9-
extern alias FrameworkV1;
10-
11-
using Assert = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
12-
using TestClass = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
13-
using TestMethod = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
14-
#endif
156
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
167
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment;
178

18-
[TestClass]
19-
public class DeploymentItemTests
9+
using TestFramework.ForTestingMSTest;
10+
11+
public class DeploymentItemTests : TestContainer
2012
{
21-
[TestMethod]
2213
public void EqualsShouldReturnFalseIfOtherItemIsNull()
2314
{
2415
DeploymentItem item = new("e:\\temp\\temp1.dll");
2516

26-
Assert.IsFalse(item.Equals(null));
17+
Verify(!item.Equals(null));
2718
}
2819

29-
[TestMethod]
3020
public void EqualsShouldReturnFalseIfOtherItemIsNotDeploymentItem()
3121
{
3222
DeploymentItem item = new("e:\\temp\\temp1.dll");
3323

34-
Assert.IsFalse(item.Equals(new DeploymentItemTests()));
24+
Verify(!item.Equals(new DeploymentItemTests()));
3525
}
3626

37-
[TestMethod]
3827
public void EqualsShouldReturnFalseIfSourcePathIsDifferent()
3928
{
4029
DeploymentItem item1 = new("e:\\temp\\temp1.dll");
4130
DeploymentItem item2 = new("e:\\temp\\temp2.dll");
4231

43-
Assert.IsFalse(item1.Equals(item2));
32+
Verify(!item1.Equals(item2));
4433
}
4534

46-
[TestMethod]
4735
public void EqualsShouldReturnFalseIfRelativeOutputDirectoryIsDifferent()
4836
{
4937
DeploymentItem item1 = new("e:\\temp\\temp1.dll", "foo1");
5038
DeploymentItem item2 = new("e:\\temp\\temp1.dll", "foo2");
5139

52-
Assert.IsFalse(item1.Equals(item2));
40+
Verify(!item1.Equals(item2));
5341
}
5442

55-
[TestMethod]
5643
public void EqualsShouldReturnTrueIfSourcePathDiffersByCase()
5744
{
5845
DeploymentItem item1 = new("e:\\temp\\temp1.dll");
5946
DeploymentItem item2 = new("e:\\temp\\Temp1.dll");
6047

61-
Assert.IsTrue(item1.Equals(item2));
48+
Verify(item1.Equals(item2));
6249
}
6350

64-
[TestMethod]
6551
public void EqualsShouldReturnTrueIfRelativeOutputDirectoryDiffersByCase()
6652
{
6753
DeploymentItem item1 = new("e:\\temp\\temp1.dll", "foo1");
6854
DeploymentItem item2 = new("e:\\temp\\temp1.dll", "Foo1");
6955

70-
Assert.IsTrue(item1.Equals(item2));
56+
Verify(item1.Equals(item2));
7157
}
7258

73-
[TestMethod]
7459
public void EqualsShouldReturnTrueIfSourceAndRelativeOutputDirectoryAreSame()
7560
{
7661
DeploymentItem item1 = new("e:\\temp\\temp1.dll", "foo1");
7762
DeploymentItem item2 = new("e:\\temp\\temp1.dll", "foo1");
7863

79-
Assert.IsTrue(item1.Equals(item2));
64+
Verify(item1.Equals(item2));
8065
}
8166

82-
[TestMethod]
8367
public void GetHashCodeShouldConsiderSourcePathAndRelativeOutputDirectory()
8468
{
8569
var sourcePath = "e:\\temp\\temp1.dll";
8670
var relativeOutputDirectory = "foo1";
8771
DeploymentItem item = new(sourcePath, relativeOutputDirectory);
8872

89-
Assert.AreEqual(sourcePath.GetHashCode() + relativeOutputDirectory.GetHashCode(), item.GetHashCode());
73+
Verify(sourcePath.GetHashCode() + relativeOutputDirectory.GetHashCode() == item.GetHashCode());
9074
}
9175

92-
[TestMethod]
9376
public void ToStringShouldReturnDeploymentItemIfRelativeOutputDirectoryIsNotSpecified()
9477
{
9578
var sourcePath = "e:\\temp\\temp1.dll";
9679
DeploymentItem item = new(sourcePath);
9780

98-
Assert.AreEqual(string.Format(Resource.DeploymentItem, sourcePath), item.ToString());
81+
Verify(string.Format(Resource.DeploymentItem, sourcePath) == item.ToString());
9982
}
10083

101-
[TestMethod]
10284
public void ToStringShouldReturnDeploymentItemAndRelativeOutputDirectory()
10385
{
10486
var sourcePath = "e:\\temp\\temp1.dll";
10587
var relativeOutputDirectory = "foo1";
10688
DeploymentItem item = new(sourcePath, relativeOutputDirectory);
10789

108-
Assert.AreEqual(string.Format(Resource.DeploymentItemWithOutputDirectory, sourcePath, relativeOutputDirectory), item.ToString());
90+
Verify(string.Format(Resource.DeploymentItemWithOutputDirectory, sourcePath, relativeOutputDirectory) == item.ToString());
10991
}
11092
}

test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Deployment/ns10TestRunDirectoriesTests.cs

+6-15
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,20 @@
33

44
namespace MSTestAdapter.PlatformServices.Tests.Deployment;
55

6-
#if NETCOREAPP
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
#else
9-
extern alias FrameworkV1;
10-
11-
using Assert = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
12-
using TestClass = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
13-
using TestMethod = FrameworkV1.Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
14-
#endif
156
using System;
167
using System.IO;
178
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment;
189

19-
[TestClass]
20-
public class TestRunDirectoriesTests
10+
using TestFramework.ForTestingMSTest;
11+
12+
public class TestRunDirectoriesTests : TestContainer
2113
{
2214
private readonly TestRunDirectories _testRunDirectories = new(@"C:\temp");
2315

24-
[TestMethod]
2516
public void InMachineNameDirectoryShouldReturnMachineSpecificDeploymentDirectory()
2617
{
27-
Assert.AreEqual(
28-
Path.Combine(@"C:\temp\In", Environment.MachineName),
29-
_testRunDirectories.InMachineNameDirectory);
18+
Verify(
19+
Path.Combine(@"C:\temp\In", Environment.MachineName)
20+
== _testRunDirectories.InMachineNameDirectory);
3021
}
3122
}

test/UnitTests/PlatformServices.Shared.Unit.Tests/netstandard1.0/Extensions/ns10ExceptionExtensionsTests.cs

+5-15
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,20 @@
33

44
namespace MSTestAdapter.PlatformServices.Tests.Extensions;
55

6-
#if NETCOREAPP
7-
using Microsoft.VisualStudio.TestTools.UnitTesting;
8-
#else
9-
extern alias FrameworkV1;
10-
11-
using Assert = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.Assert;
12-
using TestClass = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute;
13-
using TestMethod = FrameworkV1::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute;
14-
#endif
156
using System;
167

178
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Extensions;
189

19-
[TestClass]
20-
public class ExceptionExtensionsTests
10+
using TestFramework.ForTestingMSTest;
11+
12+
public class ExceptionExtensionsTests : TestContainer
2113
{
22-
[TestMethod]
2314
public void GetExceptionMessageShouldReturnExceptionMessage()
2415
{
2516
Exception ex = new("something bad happened");
26-
Assert.AreEqual("something bad happened", ex.GetExceptionMessage());
17+
Verify("something bad happened" == ex.GetExceptionMessage());
2718
}
2819

29-
[TestMethod]
3020
public void GetExceptionMessageShouldReturnInnerExceptionMessageAsWell()
3121
{
3222
Exception ex = new("something bad happened", new Exception("inner exception", new Exception("the real exception")));
@@ -37,6 +27,6 @@ public void GetExceptionMessageShouldReturnInnerExceptionMessageAsWell()
3727
Environment.NewLine,
3828
"the real exception");
3929

40-
Assert.AreEqual(expectedMessage, ex.GetExceptionMessage());
30+
Verify(expectedMessage == ex.GetExceptionMessage());
4131
}
4232
}

0 commit comments

Comments
 (0)