Skip to content

Commit c1d461d

Browse files
committed
make all the tests NUnit and run every test in its application domain
1 parent c3d6f36 commit c1d461d

5 files changed

+29
-39
lines changed

test/Typewriter.Test/Given_a_valid_metadata_file_to_Typewriter.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using System.Collections.Generic;
33
using System.IO;
44

@@ -8,7 +8,7 @@ namespace Typewriter.Test
88
/// End to end tests that check the results of running Typewriter from the CLI.
99
/// IMPORTANT: Typewriter MUST be built before as the templates need to be compiled before running the tests.
1010
/// </summary>
11-
[TestClass]
11+
[TestFixture]
1212
public class Given_a_valid_metadata_file_to_Typewriter
1313
{
1414
public string testMetadata;
@@ -18,13 +18,13 @@ public class Given_a_valid_metadata_file_to_Typewriter
1818
/// <summary>
1919
/// Load metadata from file into a string so we can validate MetadataPreprocessor.
2020
/// </summary>
21-
[TestInitialize]
21+
[SetUp]
2222
public void Initialize()
2323
{
2424
testMetadata = Typewriter.Test.Properties.Resources.dirtyMetadata;
2525
}
2626

27-
[TestMethod]
27+
[Test, RunInApplicationDomain]
2828
public void It_generates_a_typings_file()
2929
{
3030
const string outputDirectory = "output";
@@ -41,7 +41,7 @@ public void It_generates_a_typings_file()
4141
Assert.IsTrue(fileInfo.Exists, $"Expected {fileInfo.FullName}. File was not found.");
4242
}
4343

44-
[TestMethod]
44+
[Test, RunInApplicationDomain]
4545
public void It_generates_PHP_models_with_a_property()
4646
{
4747
const string testNamespace = "Beta";
@@ -77,7 +77,7 @@ public void It_generates_PHP_models_with_a_property()
7777
/// <summary>
7878
///
7979
/// </summary>
80-
[TestMethod]
80+
[Test, RunInApplicationDomain]
8181
public void It_generates_Java_models_with_disambiguated_import()
8282
{
8383
const string outputDirectory = "outputJava";
@@ -109,7 +109,7 @@ public void It_generates_Java_models_with_disambiguated_import()
109109
Assert.IsTrue(isExpectedImportStatementFound, $"The expected statement was not found. Expected: {expected}");
110110
}
111111

112-
[TestMethod]
112+
[Test, RunInApplicationDomain]
113113
public void It_generates_dotNet_client_with_default_beta_baseUrl()
114114
{
115115
const string outputDirectory = "output";
@@ -144,7 +144,7 @@ public void It_generates_dotNet_client_with_default_beta_baseUrl()
144144
}
145145

146146

147-
[TestMethod]
147+
[Test, RunInApplicationDomain]
148148
public void It_generates_dotNet_client_with_commented_out_code_comments()
149149
{
150150
const string outputDirectory = "output";
@@ -177,7 +177,7 @@ public void It_generates_dotNet_client_with_commented_out_code_comments()
177177
Assert.IsTrue(hasTestString, $"The expected test token string, '{testString}', was not set in the generated test file. We are not correctly handling the \r\n coming from the annotations.");
178178
}
179179

180-
[TestMethod]
180+
[Test, RunInApplicationDomain]
181181
public void It_generates_dotNet_odatatype_initialization_for_complextypes()
182182
{
183183
const string outputDirectory = "output";
@@ -215,7 +215,7 @@ public void It_generates_dotNet_odatatype_initialization_for_complextypes()
215215
Assert.IsTrue(hasCstorString, $"The expected test token cstor string, '{testCstorString}', was not set in the generated test file. We didn't properly generate the cstor code.");
216216
}
217217

218-
[TestMethod]
218+
[Test, RunInApplicationDomain]
219219
public void It_doesnt_generate_odatatype_initialization_for_abstract_complextypes()
220220
{
221221
const string outputDirectory = "output";
@@ -248,7 +248,7 @@ public void It_doesnt_generate_odatatype_initialization_for_abstract_complextype
248248
}
249249

250250

251-
[TestMethod]
251+
[Test, RunInApplicationDomain]
252252
public void It_generates_dotNet_odatatype_initialization_for_entitytypes()
253253
{
254254
const string outputDirectory = "output";
@@ -279,7 +279,7 @@ public void It_generates_dotNet_odatatype_initialization_for_entitytypes()
279279
Assert.IsTrue(hasTestString, $"The expected test token string, '{testString}', was not set in the generated test file. We didn't properly generate the cstor code.");
280280
}
281281

282-
[TestMethod]
282+
[Test, RunInApplicationDomain]
283283
public void It_doesnt_generate_odatatype_initialization_for_abstract_entitytypes()
284284
{
285285
const string outputDirectory = "output";
@@ -316,7 +316,7 @@ public void It_doesnt_generate_odatatype_initialization_for_abstract_entitytypes
316316
Assert.IsFalse(hasTestODataInitString, $"The unexpected test token string, '{testODataInitString}', was set in the generated test file. We didn't properly generate the cstor code.");
317317
}
318318

319-
[TestMethod]
319+
[Test, RunInApplicationDomain]
320320
public void It_creates_disambiguated_abstract_base_complextype_models()
321321
{
322322
const string outputDirectory = "output";
@@ -349,7 +349,7 @@ public void It_creates_disambiguated_abstract_base_complextype_models()
349349
Assert.IsTrue(hasTestString, $"The expected test token string, '{testString}', was not set in the generated test file. We didn't properly generate the type declaration code.");
350350
}
351351

352-
[TestMethod]
352+
[Test, RunInApplicationDomain]
353353
public void It_creates_disambiguated_complextype_models()
354354
{
355355
const string outputDirectory = "output";
@@ -399,7 +399,7 @@ public void It_creates_disambiguated_complextype_models()
399399
Assert.IsTrue(hasTestOdataType, $"The expected test token string, '{testOdataType}', was not set in the generated test file. We didn't properly generate the initialized odata.type code.");
400400
}
401401

402-
[TestMethod]
402+
[Test, RunInApplicationDomain]
403403
public void It_creates_disambiguated_MethodRequestBuilder_parameters()
404404
{
405405
const string outputDirectory = "output";
@@ -434,7 +434,7 @@ public void It_creates_disambiguated_MethodRequestBuilder_parameters()
434434
Assert.IsTrue(hasTestParameter, $"The expected test token string, '{testParameter}', was not set in the generated test file. We didn't properly generate the parameter.");
435435
}
436436

437-
[TestMethod]
437+
[Test, RunInApplicationDomain]
438438
public void It_creates_disambiguated_EntityRequestBuilder_parameters()
439439
{
440440
const string outputDirectory = "output";
@@ -469,7 +469,7 @@ public void It_creates_disambiguated_EntityRequestBuilder_parameters()
469469
Assert.IsTrue(hasTestParameter, $"The expected test token string, '{testParameter}', was not set in the generated test file. We didn't properly generate the parameter.");
470470
}
471471

472-
[TestMethod]
472+
[Test, RunInApplicationDomain]
473473
public void It_creates_disambiguated_IEntityRequestBuilder_parameters()
474474
{
475475
const string outputDirectory = "output";
@@ -504,7 +504,7 @@ public void It_creates_disambiguated_IEntityRequestBuilder_parameters()
504504
Assert.IsTrue(hasTestParameter, $"The expected test token string, '{testParameter}', was not set in the generated test file. We didn't properly generate the parameter.");
505505
}
506506

507-
[TestMethod]
507+
[Test, RunInApplicationDomain]
508508
public void It_transforms_metadata()
509509
{
510510
const string outputDirectory = "output";

test/Typewriter.Test/Given_a_valid_metadata_file_to_metadata_preprocessor.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
22

3-
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using NUnit.Framework;
44
using System.Collections.Generic;
55
using System.Linq;
66
using System.Xml.Linq;
77

88
namespace Typewriter.Test
99
{
10-
[TestClass]
10+
[TestFixture]
1111
public class Given_a_valid_metadata_file_to_metadata_preprocessor
1212
{
1313
public string testMetadata;
@@ -16,15 +16,15 @@ public class Given_a_valid_metadata_file_to_metadata_preprocessor
1616
/// <summary>
1717
/// Load metadata from file into a string so we can validate MetadataPreprocessor.
1818
/// </summary>
19-
[TestInitialize]
19+
[SetUp]
2020
public void Initialize()
2121
{
2222
testMetadata = Typewriter.Test.Properties.Resources.dirtyMetadata;
2323
testXMetadata = XDocument.Parse(testMetadata);
2424
MetadataPreprocessor.SetXMetadata(testXMetadata);
2525
}
2626

27-
[TestMethod]
27+
[Test, RunInApplicationDomain]
2828
public void It_removes_the_HasStream_attribute()
2929
{
3030
var entityToProcess = "onenotePage";
@@ -46,7 +46,7 @@ public void It_removes_the_HasStream_attribute()
4646
Assert.IsFalse(hasStreamAfter, "Expected: The HasStream aatribute is not present. Actual: HasStream is present.");
4747
}
4848

49-
[TestMethod]
49+
[Test, RunInApplicationDomain]
5050
public void It_adds_the_ContainsTarget_attribute()
5151
{
5252
var navPropTypeToProcess = "plannerPlan";
@@ -72,7 +72,7 @@ public void It_adds_the_ContainsTarget_attribute()
7272
Assert.IsTrue(doesContainTargetAfter, "Expected: ContainsTarget is true. Actual: ContainsTarget is false");
7373
}
7474

75-
[TestMethod]
75+
[Test, RunInApplicationDomain]
7676
public void It_removes_capability_annotations()
7777
{
7878
bool hasCapabilityAnnotationsBefore = MetadataPreprocessor.GetXMetadata().Descendants()
@@ -89,7 +89,7 @@ public void It_removes_capability_annotations()
8989
Assert.IsFalse(hasCapabilityAnnotationsAfter, "Expected: false, there should be no elements returned. Actual: there are capability annotations."); //
9090
}
9191

92-
[TestMethod]
92+
[Test, RunInApplicationDomain]
9393
public void It_adds_long_description_to_thumbnail()
9494
{
9595
XElement thumbnailComplexTypeBefore = MetadataPreprocessor.GetXMetadata().Descendants()
@@ -118,7 +118,7 @@ public void It_adds_long_description_to_thumbnail()
118118
/// <summary>
119119
/// Tests that we reorder parameters according to an input listof parameters.
120120
/// </summary>
121-
[TestMethod]
121+
[Test, RunInApplicationDomain]
122122
public void It_reorders_parameters_in_an_action()
123123
{
124124
/* The element to reorder from the resources/dirtymetadata.xml file.
@@ -175,7 +175,7 @@ public void It_reorders_parameters_in_an_action()
175175
/// <summary>
176176
/// Tests that we reorder parameters according to an input element name list.
177177
/// </summary>
178-
[TestMethod]
178+
[Test, RunInApplicationDomain]
179179
public void It_reorders_elements_in_a_complextype()
180180
{
181181
/* The element to reorder from the resources/dirtymetadata.xml file.
@@ -227,7 +227,7 @@ public void It_reorders_elements_in_a_complextype()
227227
"The element list was not reordered as expected.");
228228
}
229229

230-
[TestMethod]
230+
[Test, RunInApplicationDomain]
231231
public void It_does_not_reorder_when_element_list_does_not_match_in_a_complextype()
232232
{
233233
/* The element to attempt to reorder from the resources/dirtymetadata.xml file.

test/Typewriter.Test/MultipleNamespacesTestRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using System;
33
using System.Collections.Generic;
44
using System.IO;

test/Typewriter.Test/Typewriter.Test.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="..\..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" />
44
<Import Project="..\..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" />
5-
<Import Project="..\..\packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\..\packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.props')" />
65
<PropertyGroup>
76
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
87
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -40,12 +39,6 @@
4039
<WarningLevel>4</WarningLevel>
4140
</PropertyGroup>
4241
<ItemGroup>
43-
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
44-
<HintPath>..\..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
45-
</Reference>
46-
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
47-
<HintPath>..\..\packages\MSTest.TestFramework.1.2.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
48-
</Reference>
4942
<Reference Include="NUnit.ApplicationDomain, Version=11.0.0.0, Culture=neutral, PublicKeyToken=afbd8211e0c40e2c, processorArchitecture=MSIL">
5043
<HintPath>..\..\packages\NUnit.ApplicationDomain.11.1.0\lib\net40\NUnit.ApplicationDomain.dll</HintPath>
5144
</Reference>
@@ -118,7 +111,6 @@
118111
<ItemGroup />
119112
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
120113
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
121-
<Import Project="..\..\packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\..\packages\MSTest.TestAdapter.1.2.1\build\net45\MSTest.TestAdapter.targets')" />
122114
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
123115
<PropertyGroup>
124116
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>

test/Typewriter.Test/packages.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="MSTest.TestAdapter" version="1.2.1" targetFramework="net472" />
4-
<package id="MSTest.TestFramework" version="1.2.1" targetFramework="net472" />
53
<package id="NUnit" version="3.12.0" targetFramework="net472" />
64
<package id="NUnit.ApplicationDomain" version="11.1.0" targetFramework="net472" />
75
<package id="NUnit3TestAdapter" version="3.17.0" targetFramework="net472" />

0 commit comments

Comments
 (0)