diff --git a/StartPetsApi.ps1 b/StartPetsApi.ps1 index a4291b9f..88f87d99 100644 --- a/StartPetsApi.ps1 +++ b/StartPetsApi.ps1 @@ -1,9 +1,9 @@ #Launch WebApi Website and POST a request for generating client APIs cd $PSScriptRoot -$path = "$PSScriptRoot\PetWebApi\bin\Debug\net8.0" +$path = "$PSScriptRoot/PetWebApi" $procArgs = @{ FilePath = "dotnet.exe" - ArgumentList = "$path\PetWebApi.dll" + ArgumentList = "run --project $path/PetWebApi.csproj --no-build" WorkingDirectory = $path PassThru = $true } diff --git a/TestReleaseAll.ps1 b/TestReleaseAll.ps1 index 51f86a28..89e418b5 100644 --- a/TestReleaseAll.ps1 +++ b/TestReleaseAll.ps1 @@ -1 +1 @@ -dotnet test --no-build --verbosity normal --configuration Release \ No newline at end of file +dotnet test --verbosity normal --configuration Release \ No newline at end of file diff --git a/TestReleaseBasic.ps1 b/TestReleaseBasic.ps1 index 94639f13..48c01239 100644 --- a/TestReleaseBasic.ps1 +++ b/TestReleaseBasic.ps1 @@ -1,2 +1,2 @@ # Test only those suites without referecing to OpenApiDir. This is also used in DotNetRelease.yml of GitHub actions -dotnet test --no-build --verbosity normal --configuration Release --filter "(FullyQualifiedName~Tests) & (FullyQualifiedName!~OpenApiDirTests)" \ No newline at end of file +dotnet test --verbosity normal --configuration Release --filter "(FullyQualifiedName~Tests) & (FullyQualifiedName!~OpenApiDirTests)" \ No newline at end of file diff --git a/Tests/CsOpenApi3Tests/OpenApi3Tests.cs b/Tests/CsOpenApi3Tests/OpenApi3Tests.cs index ebaae123..1257d627 100644 --- a/Tests/CsOpenApi3Tests/OpenApi3Tests.cs +++ b/Tests/CsOpenApi3Tests/OpenApi3Tests.cs @@ -12,7 +12,9 @@ public partial class OpenApi3Tests const string openDirName= "openapi-directory20240114"; public OpenApi3Tests(ITestOutputHelper output) { - helper = new CSharpTestHelperForOpenApiDir(output, "openapi.yaml", OpenApi3CodeGenSettings.Default); + helper = new CSharpTestHelperForOpenApiDir(output, "openapi.yaml", OpenApi3CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success) => Assert.True(success)); } void GenerateFromOpenApiAndBuild(string filePath, ISettings mySettings = null) diff --git a/Tests/CsSwagger2Tests/ODAzureTests.cs b/Tests/CsSwagger2Tests/ODAzureTests.cs index 65d954e2..fe267189 100644 --- a/Tests/CsSwagger2Tests/ODAzureTests.cs +++ b/Tests/CsSwagger2Tests/ODAzureTests.cs @@ -12,7 +12,9 @@ public class ODAzureTests readonly CSharpTestHelperForOpenApiDir helper; public ODAzureTests(ITestOutputHelper output) { - helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default); + helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success) => Assert.True(success)); } [Fact] diff --git a/Tests/CsSwagger2Tests/ODAzureTests2.cs b/Tests/CsSwagger2Tests/ODAzureTests2.cs index 48236cf7..e766da90 100644 --- a/Tests/CsSwagger2Tests/ODAzureTests2.cs +++ b/Tests/CsSwagger2Tests/ODAzureTests2.cs @@ -11,7 +11,9 @@ public class ODAzureTests2 readonly CSharpTestHelperForOpenApiDir helper; public ODAzureTests2(ITestOutputHelper output) { - helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default); + helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success) => Assert.True(success)); } [Fact] diff --git a/Tests/CsSwagger2Tests/ODMiscTests.cs b/Tests/CsSwagger2Tests/ODMiscTests.cs index 477d08ce..7d3948cc 100644 --- a/Tests/CsSwagger2Tests/ODMiscTests.cs +++ b/Tests/CsSwagger2Tests/ODMiscTests.cs @@ -11,7 +11,9 @@ public class ODMiscTests readonly CSharpTestHelperForOpenApiDir helper; public ODMiscTests(ITestOutputHelper output) { - helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default); + helper = new CSharpTestHelperForOpenApiDir(output, "swagger.yaml", Swagger2CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success) => Assert.True(success)); } [Fact] diff --git a/Tests/CsTestHelpers/CSharpTestHelper.cs b/Tests/CsTestHelpers/CSharpTestHelper.cs index 5cb205d3..a725f6b5 100644 --- a/Tests/CsTestHelpers/CSharpTestHelper.cs +++ b/Tests/CsTestHelpers/CSharpTestHelper.cs @@ -3,7 +3,6 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; using System.IO; -using Xunit; using Xunit.Abstractions; namespace Fonlow.OpenApiClientGen.TestHelpers @@ -15,11 +14,15 @@ public class CSharpTestHelper: ITestHelper { readonly protected ITestOutputHelper output; readonly protected ISettings defaultSettings; + readonly protected Action assertEqual; + readonly protected Action assertTrue; - public CSharpTestHelper(ITestOutputHelper output, ISettings defaultSettings) + public CSharpTestHelper(ITestOutputHelper output, ISettings defaultSettings, Action assertEqual, Action assertTrue) { this.output = output; this.defaultSettings = defaultSettings; + this.assertEqual = assertEqual; + this.assertTrue = assertTrue; } static OpenApiDocument ReadDef(string filePath) @@ -64,7 +67,7 @@ public void GenerateAndAssertAndBuild(string filePath, string expectedFile, ISet else { string expected = ReadFromResults(expectedFile); - Assert.Equal(expected, s, ignoreLineEndingDifferences: true); + assertEqual(expected, s);//, ignoreLineEndingDifferences: true); } if (TestingSettings.Instance.Build) @@ -80,7 +83,7 @@ public void GenerateAndAssertAndBuild(string filePath, string expectedFile, ISet } } - Assert.True(r.Success); + assertTrue(r.Success); } } } diff --git a/Tests/CsTestHelpers/CSharpTestHelperForOpenApiDir.cs b/Tests/CsTestHelpers/CSharpTestHelperForOpenApiDir.cs index d3e96d10..f252374e 100644 --- a/Tests/CsTestHelpers/CSharpTestHelperForOpenApiDir.cs +++ b/Tests/CsTestHelpers/CSharpTestHelperForOpenApiDir.cs @@ -2,7 +2,6 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; using System.IO; -using Xunit; using Fonlow.OpenApiClientGen.CS; using Xunit.Abstractions; using System; @@ -12,7 +11,8 @@ namespace Fonlow.OpenApiClientGen.TestHelpers { public class CSharpTestHelperForOpenApiDir: CSharpTestHelper, IOpenApiDirTestHelper { - public CSharpTestHelperForOpenApiDir(ITestOutputHelper output, string defaultDefName, ISettings defaultSettings) : base(output, defaultSettings) + public CSharpTestHelperForOpenApiDir(ITestOutputHelper output, string defaultDefName, + ISettings defaultSettings, Action assertEqual, Action assertTrue) : base(output, defaultSettings, assertEqual, assertTrue) { this.defaultDefName = defaultDefName; } @@ -55,7 +55,7 @@ public void GenerateFromOpenApiAndBuild(string openapiDir, ISettings mySettings= else { string expected = File.ReadAllText(csFilePath); - Assert.Equal(expected, s, ignoreLineEndingDifferences: true); + assertEqual(expected, s); } if (TestingSettings.Instance.Build) @@ -70,7 +70,7 @@ public void GenerateFromOpenApiAndBuild(string openapiDir, ISettings mySettings= } } - Assert.True(r.Success); + assertTrue(r.Success); } } diff --git a/Tests/CsTestHelpers/CsTestHelpers.csproj b/Tests/CsTestHelpers/CsTestHelpers.csproj index 0458876a..d8e8aa50 100644 --- a/Tests/CsTestHelpers/CsTestHelpers.csproj +++ b/Tests/CsTestHelpers/CsTestHelpers.csproj @@ -7,7 +7,7 @@ - + diff --git a/Tests/NG2OpenApi3Tests/OpenApi3Tests.cs b/Tests/NG2OpenApi3Tests/OpenApi3Tests.cs index 6f84ec59..a37a9dac 100644 --- a/Tests/NG2OpenApi3Tests/OpenApi3Tests.cs +++ b/Tests/NG2OpenApi3Tests/OpenApi3Tests.cs @@ -12,7 +12,9 @@ public partial class OpenApi3Tests const string openDirName= "openapi-directory20240114"; public OpenApi3Tests(ITestOutputHelper output) { - helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output); + helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual) => Assert.Equal(expected, actual)); } } } \ No newline at end of file diff --git a/Tests/NG2Tests/ODAzureTests.cs b/Tests/NG2Tests/ODAzureTests.cs index d320e15f..df70525c 100644 --- a/Tests/NG2Tests/ODAzureTests.cs +++ b/Tests/NG2Tests/ODAzureTests.cs @@ -13,7 +13,9 @@ public partial class ODAzureTests readonly NG2OpenApiDirTestHelper helper; public ODAzureTests(ITestOutputHelper output) { - helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, "swagger.yaml"); + helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual) => Assert.Equal(expected, actual), "swagger.yaml"); } } diff --git a/Tests/NG2Tests/ODAzureTests2.cs b/Tests/NG2Tests/ODAzureTests2.cs index 034f1d61..d99262ab 100644 --- a/Tests/NG2Tests/ODAzureTests2.cs +++ b/Tests/NG2Tests/ODAzureTests2.cs @@ -12,7 +12,9 @@ public partial class ODAzureTests2 readonly NG2OpenApiDirTestHelper helper; public ODAzureTests2(ITestOutputHelper output) { - helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, "swagger.yaml"); + helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual) => Assert.Equal(expected, actual), "swagger.yaml"); } } } diff --git a/Tests/NG2Tests/ODMiscTests.cs b/Tests/NG2Tests/ODMiscTests.cs index 238ec4eb..6e2deb95 100644 --- a/Tests/NG2Tests/ODMiscTests.cs +++ b/Tests/NG2Tests/ODMiscTests.cs @@ -12,7 +12,9 @@ public partial class ODMiscTests readonly NG2OpenApiDirTestHelper helper; public ODMiscTests(ITestOutputHelper output) { - helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, "swagger.yaml"); + helper = new NG2OpenApiDirTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual) => Assert.Equal(expected, actual), "swagger.yaml"); } } } diff --git a/Tests/SwagTests/CodeGenCsTests.cs b/Tests/SwagTests/CodeGenCsTests.cs index 017f6cce..e217b992 100644 --- a/Tests/SwagTests/CodeGenCsTests.cs +++ b/Tests/SwagTests/CodeGenCsTests.cs @@ -9,7 +9,9 @@ public class CodeGenCsTests { public CodeGenCsTests(ITestOutputHelper output) { - helper = new CSharpTestHelper(output, CodeGenSettings.Default); + helper = new CSharpTestHelper(output, CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success)=> Assert.True(success)); } readonly CSharpTestHelper helper; @@ -465,7 +467,7 @@ public void TestGoogleBooks() GenerateAndAssertAndBuild("SwagMock/googleBooksOpenApi.yaml", "Results/googleBooksOpenApi.txt"); } - [Fact(Skip ="Not sure")] + [Fact(Skip = "Not sure")] public void TestAzureSecurityInsights() { GenerateAndAssertAndBuild("SwagMock/AzureSecurityInsights.yaml", "Results/AzureSecurityInsights.txt"); @@ -477,7 +479,7 @@ public void TestAzureSecurityInsights() /// /// OpenApi v3.1 /// - [Fact(Skip ="Until OpenApi v3.1 is supported by Microsoft.OpenApi.Readers")] + [Fact(Skip = "Until OpenApi v3.1 is supported by Microsoft.OpenApi.Readers")] public void Testwebhook31() { GenerateAndAssertAndBuild("SwagMock/webhook31.yaml", "Results/webhook31.txt"); diff --git a/Tests/SwagTests/VstsTests.cs b/Tests/SwagTests/VstsTests.cs index 987e6625..4095ff6b 100644 --- a/Tests/SwagTests/VstsTests.cs +++ b/Tests/SwagTests/VstsTests.cs @@ -12,7 +12,9 @@ public class VstsCsTests { public VstsCsTests(ITestOutputHelper output) { - helper = new CSharpTestHelper(output, CodeGenSettings.Default); + helper = new CSharpTestHelper(output, CodeGenSettings.Default, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (bool success) => Assert.True(success)); } readonly CSharpTestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenAureliaTests.cs b/Tests/SwagTsTests/CodeGenAureliaTests.cs index 485d53ef..b508f60f 100644 --- a/Tests/SwagTsTests/CodeGenAureliaTests.cs +++ b/Tests/SwagTsTests/CodeGenAureliaTests.cs @@ -10,7 +10,8 @@ public class CodeGenAureliaTests { public CodeGenAureliaTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsAureliaClientApiGen), TestingSettings.Instance); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsAureliaClientApiGen), TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenAxiosTests.cs b/Tests/SwagTsTests/CodeGenAxiosTests.cs index 399a4215..cc010976 100644 --- a/Tests/SwagTsTests/CodeGenAxiosTests.cs +++ b/Tests/SwagTsTests/CodeGenAxiosTests.cs @@ -10,7 +10,8 @@ public class CodeGenAxiosTests { public CodeGenAxiosTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsAxiosClientApiGen), TestingSettings.Instance); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsAxiosClientApiGen), TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenFetchTests.cs b/Tests/SwagTsTests/CodeGenFetchTests.cs index 0065f885..dc181405 100644 --- a/Tests/SwagTsTests/CodeGenFetchTests.cs +++ b/Tests/SwagTsTests/CodeGenFetchTests.cs @@ -10,7 +10,8 @@ public class CodeGenFetchTests { public CodeGenFetchTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsFetchClientApiGen), TestingSettings.Instance); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsFetchClientApiGen), TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenJqTests.cs b/Tests/SwagTsTests/CodeGenJqTests.cs index 9ad9abcd..455f9c00 100644 --- a/Tests/SwagTsTests/CodeGenJqTests.cs +++ b/Tests/SwagTsTests/CodeGenJqTests.cs @@ -10,7 +10,8 @@ public class CodeGenJqTests { public CodeGenJqTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsJqClientApiGen), TestingSettings.Instance); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsJqClientApiGen), TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenNG2BuildTests.cs b/Tests/SwagTsTests/CodeGenNG2BuildTests.cs index e2d5dfbd..9ad3b88c 100644 --- a/Tests/SwagTsTests/CodeGenNG2BuildTests.cs +++ b/Tests/SwagTsTests/CodeGenNG2BuildTests.cs @@ -10,7 +10,9 @@ public class CodeGenNG2BuildTests { public CodeGenNG2BuildTests(ITestOutputHelper output) { - helper = new NG2TestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2ClientApiGen), output, TestingSettings.Instance); + helper = new NG2TestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2ClientApiGen), output, TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual)=> Assert.Equal(expected, actual)); } readonly NG2TestHelper helper; diff --git a/Tests/SwagTsTests/CodeGenNG2FormGroupBuildTests.cs b/Tests/SwagTsTests/CodeGenNG2FormGroupBuildTests.cs index 44e041c7..ec520751 100644 --- a/Tests/SwagTsTests/CodeGenNG2FormGroupBuildTests.cs +++ b/Tests/SwagTsTests/CodeGenNG2FormGroupBuildTests.cs @@ -10,7 +10,9 @@ public class CodeGenNG2FormGroupBuildTests { public CodeGenNG2FormGroupBuildTests(ITestOutputHelper output) { - helper = new NG2TestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, TestingSettings.Instance); + helper = new NG2TestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), output, TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true), + (int expected, int actual) => Assert.Equal(expected, actual)); } readonly NG2TestHelper helper; diff --git a/Tests/SwagTsTests/ComponentsToTsTypesFormGroupTests.cs b/Tests/SwagTsTests/ComponentsToTsTypesFormGroupTests.cs index 4b9e16ed..200f49b4 100644 --- a/Tests/SwagTsTests/ComponentsToTsTypesFormGroupTests.cs +++ b/Tests/SwagTsTests/ComponentsToTsTypesFormGroupTests.cs @@ -9,7 +9,8 @@ public class ComponentsToTsTypesFormGroupTests { public ComponentsToTsTypesFormGroupTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), TestingSettings.Instance); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2FormGroupClientApiGen), TestingSettings.Instance, + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/SwagTsTests/ComponentsToTsTypesTests.cs b/Tests/SwagTsTests/ComponentsToTsTypesTests.cs index 992e38f1..2c13c256 100644 --- a/Tests/SwagTsTests/ComponentsToTsTypesTests.cs +++ b/Tests/SwagTsTests/ComponentsToTsTypesTests.cs @@ -9,7 +9,8 @@ public class ComponentsToTsTypesTests { public ComponentsToTsTypesTests() { - helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2ClientApiGen), new CasualTestingSettings(false, false)); + helper = new TsTestHelper(typeof(Fonlow.CodeDom.Web.Ts.ControllersTsNG2ClientApiGen), new CasualTestingSettings(false, false), + (string expected, string s) => Assert.Equal(expected, s, ignoreLineEndingDifferences: true)); } readonly TsTestHelper helper; diff --git a/Tests/TsTestHelpers/NG2OpenApiDirTestHelper.cs b/Tests/TsTestHelpers/NG2OpenApiDirTestHelper.cs index 9227b901..224dba35 100644 --- a/Tests/TsTestHelpers/NG2OpenApiDirTestHelper.cs +++ b/Tests/TsTestHelpers/NG2OpenApiDirTestHelper.cs @@ -19,8 +19,10 @@ public class NG2OpenApiDirTestHelper: NG2TestHelper, IOpenApiDirTestHelper /// /// /// default is openapi.yaml - public NG2OpenApiDirTestHelper(Type genType, ITestOutputHelper output, string defaultDefFile="openapi.yaml", ISettings defaultSettings=null) : base(genType, output, - new CasualTestingSettings(TestHelpers.TestingSettings.Instance.Build, TestHelpers.TestingSettings.Instance.UpdateGenerated)) + public NG2OpenApiDirTestHelper(Type genType, ITestOutputHelper output, + Action assertEqual, Action assertEqualInt, string defaultDefFile="openapi.yaml", ISettings defaultSettings=null) + : base(genType, output, + new CasualTestingSettings(TestHelpers.TestingSettings.Instance.Build, TestHelpers.TestingSettings.Instance.UpdateGenerated), assertEqual, assertEqualInt) { this.defaultDefFile = defaultDefFile; this.defaultSettings = defaultSettings; diff --git a/Tests/TsTestHelpers/NG2TestHelper.cs b/Tests/TsTestHelpers/NG2TestHelper.cs index bf23b418..1dd46cd9 100644 --- a/Tests/TsTestHelpers/NG2TestHelper.cs +++ b/Tests/TsTestHelpers/NG2TestHelper.cs @@ -15,11 +15,14 @@ public class NG2TestHelper : TsTestHelper, ITestHelper { readonly ITestOutputHelper output; readonly bool buildToValidate; + readonly Action assertEqualInt; - public NG2TestHelper(Type genType, ITestOutputHelper output, ITestingSettings testingSettings) : base(genType, testingSettings) + public NG2TestHelper(Type genType, ITestOutputHelper output, ITestingSettings testingSettings, Action assertEqual, Action assertEqualInt) + : base(genType, testingSettings, assertEqual) { this.output = output; this.buildToValidate = testingSettings.Build; + this.assertEqualInt = assertEqualInt; } public void GenerateAndAssertAndBuild(string openApiFile, string expectedFile, ISettings settings = null) @@ -41,12 +44,12 @@ public void GenerateAndAssertAndBuild(string openApiFile, string expectedFile, I else { string expected = ReadFromResults(expectedFile); - Assert.Equal(expected, s, ignoreLineEndingDifferences: true); + assertEqual(expected, s); } if (buildToValidate) { - Assert.Equal(0, CheckNGBuild(s)); + assertEqualInt(0, CheckNGBuild(s)); } } diff --git a/Tests/TsTestHelpers/TsTestHelper.cs b/Tests/TsTestHelpers/TsTestHelper.cs index 74cd2bc1..dce22877 100644 --- a/Tests/TsTestHelpers/TsTestHelper.cs +++ b/Tests/TsTestHelpers/TsTestHelper.cs @@ -18,14 +18,16 @@ public class TsTestHelper /// /// /// Code gen Type to be instantiated. - public TsTestHelper(Type codeGenType, ITestingSettings testingSettings) + public TsTestHelper(Type codeGenType, ITestingSettings testingSettings, Action assertEqual) { this.codeGenType = codeGenType; this.testingSettings = testingSettings; + this.assertEqual = assertEqual; } readonly Type codeGenType; protected readonly ITestingSettings testingSettings; + protected readonly Action assertEqual; static OpenApiDocument ReadOpenApiDef(string filePath) { @@ -116,7 +118,7 @@ public void GenerateAndAssert(string openApiFile, string expectedFile, ISettings } string expected = ReadFromResults(expectedFile); - Assert.Equal(expected, s, ignoreLineEndingDifferences: true); + assertEqual(expected, s); } } diff --git a/Tests/TsTestHelpers/TsTestHelpers.csproj b/Tests/TsTestHelpers/TsTestHelpers.csproj index 2ba71311..b9e5aef5 100644 --- a/Tests/TsTestHelpers/TsTestHelpers.csproj +++ b/Tests/TsTestHelpers/TsTestHelpers.csproj @@ -9,7 +9,7 @@ - +