diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f59e3fd..290bb52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Dotnet unit test on windows if: matrix.os == 'windows-latest' @@ -45,7 +45,6 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - dotnet: [7.0.x, 6.0.x] steps: - uses: actions/checkout@v3 @@ -62,7 +61,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - uses: getgauge/setup-gauge@master with: @@ -86,14 +85,14 @@ jobs: if: matrix.os != 'windows-latest' run: | cd gauge-tests - ./gradlew clean dotnetFT + ./gradlew -Pnodes=2 clean dotnetFT - name: Run FTs on windows if: matrix.os == 'windows-latest' shell: pwsh run: | cd gauge-tests - .\gradlew.bat clean dotnetFT + .\gradlew.bat -Pnodes=2 clean dotnetFT - uses: actions/upload-artifact@v3 if: failure() @@ -118,7 +117,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - uses: getgauge/setup-gauge@master with: diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index bc2b7b6..b753398 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Setup git run: | diff --git a/integration-test/ExecuteStepProcessorTests.cs b/integration-test/ExecuteStepProcessorTests.cs index f92a4e8..0009623 100644 --- a/integration-test/ExecuteStepProcessorTests.cs +++ b/integration-test/ExecuteStepProcessorTests.cs @@ -5,12 +5,13 @@ *----------------------------------------------------------------*/ +using System.Threading; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Wrappers; using Gauge.Messages; using NUnit.Framework; -using System.Threading; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -66,8 +67,8 @@ public void ShouldExecuteMethodFromRequest() var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; - Assert.IsNotNull(protoExecutionResult); - Assert.IsFalse(protoExecutionResult.Failed); + ClassicAssert.IsNotNull(protoExecutionResult); + ClassicAssert.IsFalse(protoExecutionResult.Failed); } [Test] @@ -98,9 +99,9 @@ public void ShouldCaptureScreenshotOnFailure() var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; - Assert.IsNotNull(protoExecutionResult); - Assert.IsTrue(protoExecutionResult.Failed); - Assert.AreEqual("screenshot.png", protoExecutionResult.FailureScreenshotFile); + ClassicAssert.IsNotNull(protoExecutionResult); + ClassicAssert.IsTrue(protoExecutionResult.Failed); + ClassicAssert.AreEqual("screenshot.png", protoExecutionResult.FailureScreenshotFile); } } } \ No newline at end of file diff --git a/integration-test/ExecutionOrchestratorTests.cs b/integration-test/ExecutionOrchestratorTests.cs index b5a1a4d..f0b72f3 100644 --- a/integration-test/ExecutionOrchestratorTests.cs +++ b/integration-test/ExecutionOrchestratorTests.cs @@ -11,6 +11,7 @@ using Gauge.Dotnet.Models; using Gauge.Dotnet.Wrappers; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -33,8 +34,8 @@ public void RecoverableIsTrueOnExceptionThrownWhenContinueOnFailure() var gaugeMethod = assemblyLoader.GetStepRegistry() .MethodFor("I throw a serializable exception and continue"); var executionResult = orchestrator.ExecuteStep(gaugeMethod); - Assert.IsTrue(executionResult.Failed); - Assert.IsTrue(executionResult.RecoverableError); + ClassicAssert.IsTrue(executionResult.Failed); + ClassicAssert.IsTrue(executionResult.RecoverableError); } [Test] @@ -56,7 +57,7 @@ public void ShouldCreateTableFromTargetType() table.AddRow(new List { "foorow2", "barrow2" }); var executionResult = orchestrator.ExecuteStep(gaugeMethod, SerializeTable(table)); - Assert.False(executionResult.Failed); + ClassicAssert.False(executionResult.Failed); } [Test] @@ -76,7 +77,7 @@ public void ShouldExecuteMethodAndReturnResult() .MethodFor("A context step which gets executed before every scenario"); var executionResult = orchestrator.ExecuteStep(gaugeMethod); - Assert.False(executionResult.Failed); + ClassicAssert.False(executionResult.Failed); } [Test] @@ -97,8 +98,8 @@ public void ShouldGetPendingMessages() var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "world"); - Assert.False(executionResult.Failed); - Assert.Contains("hello, world!", executionResult.Message); + ClassicAssert.False(executionResult.Failed); + ClassicAssert.Contains("hello, world!", executionResult.Message); } [Test] @@ -119,8 +120,8 @@ public void ShouldExecuteAsyncStepImplementation() var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod, "hello", "async world"); - Assert.False(executionResult.Failed, executionResult.ErrorMessage); - Assert.Contains("hello, async world!", executionResult.Message); + Assert.That(executionResult.Failed, Is.False, executionResult.ErrorMessage); + StringAssert.Contains("hello, async world!", executionResult.Message.ToString()); } [Test] @@ -140,9 +141,9 @@ public void ShouldGetStacktraceForAggregateException() var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an AggregateException"); var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod); - Assert.True(executionResult.Failed); - Assert.True(executionResult.StackTrace.Contains("First Exception")); - Assert.True(executionResult.StackTrace.Contains("Second Exception")); + ClassicAssert.True(executionResult.Failed); + ClassicAssert.True(executionResult.StackTrace.Contains("First Exception")); + ClassicAssert.True(executionResult.StackTrace.Contains("Second Exception")); } [Test] @@ -156,8 +157,8 @@ public void ShouldGetStepTextsForMethod() var gaugeMethod = registry.MethodFor("and an alias"); var stepTexts = gaugeMethod.Aliases.ToList(); - Assert.Contains("Step with text", stepTexts); - Assert.Contains("and an alias", stepTexts); + ClassicAssert.Contains("Step with text", stepTexts); + ClassicAssert.Contains("and an alias", stepTexts); } [Test] @@ -178,8 +179,8 @@ public void SuccessIsFalseOnSerializableExceptionThrown() var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod); - Assert.True(executionResult.Failed); - Assert.AreEqual(expectedMessage, executionResult.ErrorMessage); + ClassicAssert.True(executionResult.Failed); + ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage); StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowSerializableException", executionResult.StackTrace); } @@ -201,8 +202,8 @@ public void SuccessIsFalseOnUnserializableExceptionThrown() var gaugeMethod = assemblyLoader.GetStepRegistry().MethodFor("I throw an unserializable exception"); var executionResult = executionOrchestrator.ExecuteStep(gaugeMethod); - Assert.True(executionResult.Failed); - Assert.AreEqual(expectedMessage, executionResult.ErrorMessage); + ClassicAssert.True(executionResult.Failed); + ClassicAssert.AreEqual(expectedMessage, executionResult.ErrorMessage); StringAssert.Contains("IntegrationTestSample.StepImplementation.ThrowUnserializableException", executionResult.StackTrace); } diff --git a/integration-test/ExternalReferenceTests.cs b/integration-test/ExternalReferenceTests.cs index c7d1f9a..d7df069 100644 --- a/integration-test/ExternalReferenceTests.cs +++ b/integration-test/ExternalReferenceTests.cs @@ -12,6 +12,7 @@ using Gauge.Dotnet.Wrappers; using Gauge.Messages; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -35,7 +36,7 @@ public void ShouldGetStepsFromReference(string referenceType, string stepText, s }; var result = stepValidationProcessor.Process(message); - Assert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}"); + ClassicAssert.IsTrue(result.IsValid, $"Expected valid step text, got error: {result.ErrorMessage}"); } @@ -68,9 +69,9 @@ public void ShouldRegisterScreenshotWriterFromReference(string referenceType, st var result = executeStepProcessor.Process(message); var protoExecutionResult = result.ExecutionResult; - Assert.IsNotNull(protoExecutionResult); + ClassicAssert.IsNotNull(protoExecutionResult); Console.WriteLine(protoExecutionResult.ScreenshotFiles[0]); - Assert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected); + ClassicAssert.AreEqual(protoExecutionResult.ScreenshotFiles[0], expected); } [TearDown] diff --git a/integration-test/Gauge.Dotnet.IntegrationTests.csproj b/integration-test/Gauge.Dotnet.IntegrationTests.csproj index 2abfa6e..a28a77f 100644 --- a/integration-test/Gauge.Dotnet.IntegrationTests.csproj +++ b/integration-test/Gauge.Dotnet.IntegrationTests.csproj @@ -1,13 +1,13 @@ - net7.0 + net8.0 - - - + + + diff --git a/integration-test/ImplementCodeProcessorTests.cs b/integration-test/ImplementCodeProcessorTests.cs index 343ce11..3a33018 100644 --- a/integration-test/ImplementCodeProcessorTests.cs +++ b/integration-test/ImplementCodeProcessorTests.cs @@ -10,6 +10,7 @@ using Gauge.Dotnet.Processors; using Gauge.Messages; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -29,12 +30,12 @@ public void ShouldProcessMessage() var processor = new StubImplementationCodeProcessor(); var result = processor.Process(message); - Assert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FilePath)); - Assert.AreEqual(1, result.TextDiffs.Count); + ClassicAssert.AreEqual("StepImplementation1.cs", Path.GetFileName(result.FilePath)); + ClassicAssert.AreEqual(1, result.TextDiffs.Count); Console.WriteLine(result.TextDiffs[0].Content); - Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); - Assert.True(result.TextDiffs[0].Content.Contains("class StepImplementation1")); - Assert.AreEqual(result.TextDiffs[0].Span.Start, 0); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("class StepImplementation1")); + ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 0); } [Test] @@ -52,11 +53,11 @@ public void ShouldProcessMessageForExistingButEmptyFile() var processor = new StubImplementationCodeProcessor(); var result = processor.Process(message); - Assert.AreEqual(1, result.TextDiffs.Count); - Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); - Assert.True(result.TextDiffs[0].Content.Contains("class Empty")); + ClassicAssert.AreEqual(1, result.TextDiffs.Count); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("class Empty")); StringAssert.Contains("Step Method", result.TextDiffs[0].Content); - Assert.AreEqual(result.TextDiffs[0].Span.Start, 0); + ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 0); } [Test] @@ -74,9 +75,9 @@ public void ShouldProcessMessageForExistingClass() var processor = new StubImplementationCodeProcessor(); var result = processor.Process(message); - Assert.AreEqual(1, result.TextDiffs.Count); + ClassicAssert.AreEqual(1, result.TextDiffs.Count); StringAssert.Contains("Step Method", result.TextDiffs[0].Content); - Assert.AreEqual(115, result.TextDiffs[0].Span.Start); + ClassicAssert.AreEqual(115, result.TextDiffs[0].Span.Start); } [Test] @@ -94,10 +95,10 @@ public void ShouldProcessMessageForExistingFileWithEmptyClass() var processor = new StubImplementationCodeProcessor(); var result = processor.Process(message); - Assert.AreEqual(1, result.TextDiffs.Count); + ClassicAssert.AreEqual(1, result.TextDiffs.Count); StringAssert.Contains("Step Method", result.TextDiffs[0].Content); - Assert.True(result.TextDiffs[0].Content.Contains("Step Method")); - Assert.AreEqual(result.TextDiffs[0].Span.Start, 8); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("Step Method")); + ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 8); } [Test] @@ -105,21 +106,21 @@ public void ShouldProcessMessageForExistingFileWithSomeComments() { var file = Path.Combine(_testProjectPath, "CommentFile.cs"); var message = new StubImplementationCodeRequest - { - ImplementationFilePath = file, - Codes = + { + ImplementationFilePath = file, + Codes = { "Step Method" } - }; + }; var processor = new StubImplementationCodeProcessor(); var result = processor.Process(message); - Assert.AreEqual(1, result.TextDiffs.Count); + ClassicAssert.AreEqual(1, result.TextDiffs.Count); StringAssert.Contains("Step Method", result.TextDiffs[0].Content); - Assert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); - Assert.True(result.TextDiffs[0].Content.Contains("class CommentFile")); - Assert.AreEqual(result.TextDiffs[0].Span.Start, 3); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("namespace Sample")); + ClassicAssert.True(result.TextDiffs[0].Content.Contains("class CommentFile")); + ClassicAssert.AreEqual(result.TextDiffs[0].Span.Start, 3); } } } \ No newline at end of file diff --git a/integration-test/RefactorHelperTests.cs b/integration-test/RefactorHelperTests.cs index a51fa93..c38b9b5 100644 --- a/integration-test/RefactorHelperTests.cs +++ b/integration-test/RefactorHelperTests.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -40,7 +41,7 @@ public void TearDown() private readonly string _testProjectPath = TestUtils.GetIntegrationTestSampleDirectory(); - private void AssertStepAttributeWithTextExists(RefactoringChange result, string methodName, string text) + private void ClassicAssertStepAttributeWithTextExists(RefactoringChange result, string methodName, string text) { var name = methodName.Split('.').Last().Split('-').First(); var tree = @@ -49,7 +50,7 @@ private void AssertStepAttributeWithTextExists(RefactoringChange result, string var stepTexts = root.DescendantNodes().OfType() .Select( - node => new {node, attributeSyntaxes = node.AttributeLists.SelectMany(syntax => syntax.Attributes)}) + node => new { node, attributeSyntaxes = node.AttributeLists.SelectMany(syntax => syntax.Attributes) }) .Where(t => string.CompareOrdinal(t.node.Identifier.ValueText, name) == 0 && t.attributeSyntaxes.Any( @@ -57,10 +58,10 @@ private void AssertStepAttributeWithTextExists(RefactoringChange result, string .SelectMany(t => t.node.AttributeLists.SelectMany(syntax => syntax.Attributes)) .SelectMany(syntax => syntax.ArgumentList.Arguments) .Select(syntax => syntax.GetText().ToString().Trim('"')); - Assert.True(stepTexts.Contains(text)); + ClassicAssert.True(stepTexts.Contains(text)); } - private void AssertParametersExist(RefactoringChange result, string methodName, + private void ClassicAssertParametersExist(RefactoringChange result, string methodName, IReadOnlyList parameters) { var name = methodName.Split('.').Last().Split('-').First(); @@ -75,7 +76,7 @@ private void AssertParametersExist(RefactoringChange result, string methodName, .ToArray(); for (var i = 0; i < parameters.Count; i++) - Assert.AreEqual(parameters[i], methodParameters[i]); + ClassicAssert.AreEqual(parameters[i], methodParameters[i]); } [Test] @@ -92,10 +93,10 @@ public void ShouldAddParameters() var parameterPositions = new[] {new Tuple(0, 0), new Tuple(1, 1), new Tuple(-1, 2)}; var changes = RefactorHelper.Refactor(gaugeMethod, parameterPositions, - new List {"what", "who", "where"}, + new List { "what", "who", "where" }, newStepValue); - AssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); - AssertParametersExist(changes, gaugeMethod.Name, new[] {"what", "who", "where"}); + ClassicAssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); + ClassicAssertParametersExist(changes, gaugeMethod.Name, new[] { "what", "who", "where" }); } [Test] @@ -108,13 +109,13 @@ public void ShouldAddParametersWhenNoneExisted() ClassName = "RefactoringSample", FileName = Path.Combine(_testProjectPath, "RefactoringSample.cs") }; - var parameterPositions = new[] {new Tuple(-1, 0)}; + var parameterPositions = new[] { new Tuple(-1, 0) }; var changes = - RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List {"foo"}, newStepValue); + RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List { "foo" }, newStepValue); - AssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); - AssertParametersExist(changes, gaugeMethod.Name, new[] {"foo"}); + ClassicAssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); + ClassicAssertParametersExist(changes, gaugeMethod.Name, new[] { "foo" }); } [Test] @@ -128,13 +129,13 @@ public void ShouldAddParametersWithReservedKeywordName() ClassName = "RefactoringSample", FileName = Path.Combine(_testProjectPath, "RefactoringSample.cs") }; - var parameterPositions = new[] {new Tuple(-1, 0)}; + var parameterPositions = new[] { new Tuple(-1, 0) }; - var changes = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List {"class"}, + var changes = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List { "class" }, newStepValue); - AssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); - AssertParametersExist(changes, gaugeMethod.Name, new[] {"@class"}); + ClassicAssertStepAttributeWithTextExists(changes, gaugeMethod.Name, newStepValue); + ClassicAssertParametersExist(changes, gaugeMethod.Name, new[] { "@class" }); } [Test] @@ -152,7 +153,7 @@ public void ShouldRefactorAndReturnFilesChanged() var changes = RefactorHelper.Refactor(gaugeMethod, new List>(), new List(), "foo"); - Assert.AreEqual(expectedPath, changes.FileName); + ClassicAssert.AreEqual(expectedPath, changes.FileName); } [Test] @@ -166,7 +167,7 @@ public void ShouldRefactorAttributeText() }; var changes = RefactorHelper.Refactor(gaugeMethod, new List>(), new List(), "foo"); - AssertStepAttributeWithTextExists(changes, gaugeMethod.Name, "foo"); + ClassicAssertStepAttributeWithTextExists(changes, gaugeMethod.Name, "foo"); } [Test] @@ -178,12 +179,12 @@ public void ShouldRemoveParameters() ClassName = "RefactoringSample", FileName = Path.Combine(_testProjectPath, "RefactoringSample.cs") }; - var parameterPositions = new[] {new Tuple(0, 0)}; + var parameterPositions = new[] { new Tuple(0, 0) }; var changes = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List(), "Refactoring Say to someone"); - AssertParametersExist(changes, gaugeMethod.Name, new[] {"what"}); + ClassicAssertParametersExist(changes, gaugeMethod.Name, new[] { "what" }); } [Test] @@ -196,12 +197,12 @@ public void ShouldRemoveParametersInAnyOrder() FileName = Path.Combine(_testProjectPath, "RefactoringSample.cs") }; - var parameterPositions = new[] {new Tuple(1, 0)}; + var parameterPositions = new[] { new Tuple(1, 0) }; var changes = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List(), "Refactoring Say something to "); - AssertParametersExist(changes, gaugeMethod.Name, new[] {"who"}); + ClassicAssertParametersExist(changes, gaugeMethod.Name, new[] { "who" }); } [Test] @@ -216,14 +217,14 @@ public void ShouldReorderParameters() FileName = Path.Combine(_testProjectPath, "RefactoringSample.cs") }; - var parameterPositions = new[] {new Tuple(0, 1), new Tuple(1, 0)}; - var result = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List {"who", "what"}, + var parameterPositions = new[] { new Tuple(0, 1), new Tuple(1, 0) }; + var result = RefactorHelper.Refactor(gaugeMethod, parameterPositions, new List { "who", "what" }, newStepValue); - AssertStepAttributeWithTextExists(result, gaugeMethod.Name, newStepValue); - AssertParametersExist(result, gaugeMethod.Name, new[] {"who", "what"}); - Assert.True(result.Diffs.Any(d => d.Content == "\"Refactoring Say to \"")); - Assert.True(result.Diffs.Any(d => d.Content == "(string who,string what)")); + ClassicAssertStepAttributeWithTextExists(result, gaugeMethod.Name, newStepValue); + ClassicAssertParametersExist(result, gaugeMethod.Name, new[] { "who", "what" }); + ClassicAssert.True(result.Diffs.Any(d => d.Content == "\"Refactoring Say to \"")); + ClassicAssert.True(result.Diffs.Any(d => d.Content == "(string who,string what)")); } } } \ No newline at end of file diff --git a/integration-test/RefactorProcessorTests.cs b/integration-test/RefactorProcessorTests.cs index 64dfeca..d1a1fb3 100644 --- a/integration-test/RefactorProcessorTests.cs +++ b/integration-test/RefactorProcessorTests.cs @@ -11,6 +11,7 @@ using Gauge.Dotnet.Processors; using Gauge.Messages; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.IntegrationTests { @@ -65,7 +66,7 @@ public void ShouldAddParameters() var refactorProcessor = new RefactorProcessor(stepRegistry); var result = refactorProcessor.Process(message); - Assert.IsTrue(result.Success); + ClassicAssert.IsTrue(result.Success); } [TearDown] diff --git a/run.cmd b/run.cmd index 253741b..296e69a 100644 --- a/run.cmd +++ b/run.cmd @@ -1,9 +1,13 @@ @echo off -set tasks=build test package install uninstall forceinstall +set tasks=build, test, package, install, uninstall, forceinstall + +if [%1] == [] goto :usage + for %%a in (%tasks%) do ( - if %1==%%a goto %1 + if %%a==%1 goto %1 ) +:usage echo Options: "[build | test | package | install | uninstall | forceinstall]" goto :eof @@ -22,6 +26,7 @@ goto :eof rmdir /s /q deploy artifacts dotnet publish -c release -o .\deploy\bin\net6.0 src\Gauge.Dotnet.csproj -f net6.0 dotnet publish -c release -o .\deploy\bin\net7.0 src\Gauge.Dotnet.csproj -f net7.0 + dotnet publish -c release -o .\deploy\bin\net8.0 src\Gauge.Dotnet.csproj -f net8.0 copy src\launcher.sh deploy\ copy src\launcher.cmd deploy\ copy src\dotnet.json deploy\ diff --git a/run.sh b/run.sh index f3212ce..30c0259 100755 --- a/run.sh +++ b/run.sh @@ -31,6 +31,7 @@ function package() { rm -rf deploy artifacts dotnet publish -c release -o ./deploy/bin/net6.0 src/Gauge.Dotnet.csproj -f net6.0 dotnet publish -c release -o ./deploy/bin/net7.0 src/Gauge.Dotnet.csproj -f net7.0 + dotnet publish -c release -o ./deploy/bin/net8.0 src/Gauge.Dotnet.csproj -f net8.0 cp src/launcher.sh deploy cp src/launcher.cmd deploy cp src/dotnet.json deploy diff --git a/src/Exceptions/GaugeLibVersionMismatchException.cs b/src/Exceptions/GaugeLibVersionMismatchException.cs index 4436e7c..fe7992d 100644 --- a/src/Exceptions/GaugeLibVersionMismatchException.cs +++ b/src/Exceptions/GaugeLibVersionMismatchException.cs @@ -6,7 +6,6 @@ using System; -using System.Runtime.Serialization; namespace Gauge.Dotnet.Exceptions { @@ -24,9 +23,5 @@ public GaugeLibVersionMismatchException(Version targetLibVersion, Version expect public GaugeLibVersionMismatchException() { } - - public GaugeLibVersionMismatchException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } } } \ No newline at end of file diff --git a/src/Gauge.Dotnet.csproj b/src/Gauge.Dotnet.csproj index 4d3c0a7..7fdfefd 100644 --- a/src/Gauge.Dotnet.csproj +++ b/src/Gauge.Dotnet.csproj @@ -2,10 +2,10 @@ Exe - net6.0;net7.0 + net6.0;net7.0;net8.0 Runner.NetCore30 The Gauge Team - 0.5.2 + 0.5.3 ThoughtWorks Inc. Gauge C# runner for Gauge. https://gauge.org @@ -25,9 +25,12 @@ - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/Models/ExecutionResult.cs b/src/Models/ExecutionResult.cs index 65de28e..55da886 100644 --- a/src/Models/ExecutionResult.cs +++ b/src/Models/ExecutionResult.cs @@ -23,6 +23,7 @@ public class ExecutionResult : MarshalByRefObject public bool Recoverable { get; set; } + [Obsolete] public override object InitializeLifetimeService() { return null; diff --git a/src/SetupCommand.cs b/src/SetupCommand.cs index e8bbc02..65cf5b2 100644 --- a/src/SetupCommand.cs +++ b/src/SetupCommand.cs @@ -23,12 +23,12 @@ Task IGaugeCommand.Execute() var project = $@" - netstandard2.1 + net8.0 - - + + diff --git a/src/dotnet.json b/src/dotnet.json index 05cedb6..b2c6614 100644 --- a/src/dotnet.json +++ b/src/dotnet.json @@ -1,7 +1,7 @@ { "id": "dotnet", - "version": "0.5.2", - "description": "C# support for gauge + .NET 6.0/7.0 ", + "version": "0.5.3", + "description": "C# support for gauge + .NET 6.0/7.0/8.0", "run": { "windows": [ "launcher.cmd", diff --git a/src/launcher.cmd b/src/launcher.cmd index fb89bed..df51b1e 100644 --- a/src/launcher.cmd +++ b/src/launcher.cmd @@ -2,11 +2,17 @@ FOR /F "delims=" %%i IN ('dotnet --version') DO set DOTNET_VER=%%i if "6." == "%DOTNET_VER:~0,2%" goto :net6 +if "7." == "%DOTNET_VER:~0,2%" goto :net7 -dotnet bin\net7.0\Gauge.Dotnet.dll %* +dotnet bin\net8.0\Gauge.Dotnet.dll %* if %errorlevel% neq 0 exit /b %errorlevel% goto :eof :net6 dotnet bin\net6.0\Gauge.Dotnet.dll %* if %errorlevel% neq 0 exit /b %errorlevel% + goto :eof +:net7 + dotnet bin\net7.0\Gauge.Dotnet.dll %* + if %errorlevel% neq 0 exit /b %errorlevel% + goto :eof diff --git a/src/launcher.sh b/src/launcher.sh index c9f125e..2e379f8 100755 --- a/src/launcher.sh +++ b/src/launcher.sh @@ -4,5 +4,6 @@ command -v $dotnet >/dev/null 2>&1 || { echo >&2 "dotnet is not installed, abort case "$(dotnet --version)" in 6.*) dotnet bin/net6.0/Gauge.Dotnet.dll $@ ;; - *) dotnet bin/net7.0/Gauge.Dotnet.dll $@ ;; + 7.*) dotnet bin/net7.0/Gauge.Dotnet.dll $@ ;; + *) dotnet bin/net8.0/Gauge.Dotnet.dll $@ ;; esac diff --git a/test/AssemblyLoaderTests.cs b/test/AssemblyLoaderTests.cs index a31edb3..0ec8651 100644 --- a/test/AssemblyLoaderTests.cs +++ b/test/AssemblyLoaderTests.cs @@ -13,6 +13,7 @@ using Gauge.Dotnet.Wrappers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -30,7 +31,7 @@ public void Setup() _mockStepMethod = new Mock(); var mockStepAttribute = new Mock(); _mockStepMethod.Setup(x => x.GetCustomAttributes(false)) - .Returns(new[] {mockStepAttribute.Object}); + .Returns(new[] { mockStepAttribute.Object }); mockStepAttributeType.Setup(x => x.IsInstanceOfType(mockStepAttribute.Object)) .Returns(true); mockStepAttributeType.Setup(x => x.FullName).Returns(LibType.Step.FullName()); @@ -38,7 +39,7 @@ public void Setup() mockIClassInstanceManagerType.Setup(x => x.FullName).Returns("Gauge.CSharp.Lib.IClassInstanceManager"); _mockInstanceManagerType = new Mock(); _mockInstanceManagerType.Setup(type => type.GetInterfaces()) - .Returns(new[] {mockIClassInstanceManagerType.Object}); + .Returns(new[] { mockIClassInstanceManagerType.Object }); _mockInstanceManagerType.Setup(x => x.Name) .Returns("TestInstanceManager"); @@ -48,7 +49,7 @@ public void Setup() _mockScreenshotWriterType.Setup(x => x.Name) .Returns("TestScreenGrabber"); _mockScreenshotWriterType.Setup(x => x.GetInterfaces()) - .Returns(new[] {mockIScreenshotWriter.Object}); + .Returns(new[] { mockIScreenshotWriter.Object }); _assemblyName = new AssemblyName("Mock.Test.Assembly"); _mockAssembly.Setup(assembly => assembly.ExportedTypes) .Returns(new[] @@ -63,25 +64,25 @@ public void Setup() var mockGaugeScreenshotsType = new Mock(); mockGaugeScreenshotsType.Setup(x => x.FullName).Returns("Gauge.CSharp.Lib.GaugeScreenshots"); _mockAssembly.Setup(assembly => assembly.GetReferencedAssemblies()) - .Returns(new[] {libAssemblyName}); + .Returns(new[] { libAssemblyName }); _mockLibAssembly = new Mock(); _mockLibAssembly.Setup(x => x.GetName()).Returns(libAssemblyName); _mockLibAssembly.Setup(x => x.ExportedTypes) - .Returns(new[] {mockStepAttributeType.Object, mockGaugeScreenshotsType.Object}); + .Returns(new[] { mockStepAttributeType.Object, mockGaugeScreenshotsType.Object }); var mockReflectionWrapper = new Mock(); mockReflectionWrapper.Setup(r => r.GetMethods(mockStepAttributeType.Object)) - .Returns(new[] {_mockStepMethod.Object}); + .Returns(new[] { _mockStepMethod.Object }); var mockScreenshotWriter = new Mock(); mockActivationWrapper.Setup(x => x.CreateInstance(_mockScreenshotWriterType.Object)).Returns(mockScreenshotWriter); mockReflectionWrapper.Setup(x => x.InvokeMethod(mockGaugeScreenshotsType.Object, null, "RegisterCustomScreenshotWriter", - BindingFlags.Static | BindingFlags.Public, new[] {mockScreenshotWriter})); + BindingFlags.Static | BindingFlags.Public, new[] { mockScreenshotWriter })); _mockGaugeLoadContext = new Mock(); _mockGaugeLoadContext.Setup(x => x.LoadFromAssemblyName(It.Is(x => x.FullName == _assemblyName.FullName))) .Returns(_mockAssembly.Object); _mockGaugeLoadContext.Setup(x => x.LoadFromAssemblyName(It.Is(x => x.FullName == libAssemblyName.FullName))) .Returns(_mockLibAssembly.Object); _mockGaugeLoadContext.Setup(x => x.GetAssembliesReferencingGaugeLib()) - .Returns(new[] {_mockAssembly.Object}); + .Returns(new[] { _mockAssembly.Object }); _assemblyLoader = new AssemblyLoader(Path.Combine(_assemblyLocation, "Mock.Test.Assembly.dll"), _mockGaugeLoadContext.Object, mockReflectionWrapper.Object, mockActivationWrapper.Object, new StepRegistry()); } @@ -107,25 +108,25 @@ public void TearDown() [Test] public void ShouldGetAssemblyReferencingGaugeLib() { - Assert.Contains(_mockAssembly.Object, _assemblyLoader.AssembliesReferencingGaugeLib); + ClassicAssert.Contains(_mockAssembly.Object, _assemblyLoader.AssembliesReferencingGaugeLib); } [Test] public void ShouldGetClassInstanceManagerType() { - Assert.AreEqual(_mockInstanceManagerType.Object.Name, _assemblyLoader.ClassInstanceManagerType.Name); + ClassicAssert.AreEqual(_mockInstanceManagerType.Object.Name, _assemblyLoader.ClassInstanceManagerType.Name); } [Test] public void ShouldGetMethodsForGaugeAttribute() { - Assert.Contains(_mockStepMethod.Object, _assemblyLoader.GetMethods(LibType.Step).ToList()); + ClassicAssert.Contains(_mockStepMethod.Object, _assemblyLoader.GetMethods(LibType.Step).ToList()); } [Test] public void ShouldGetScreenGrabberType() { - Assert.AreEqual(_mockScreenshotWriterType.Object.Name, _assemblyLoader.ScreenshotWriter.Name); + ClassicAssert.AreEqual(_mockScreenshotWriterType.Object.Name, _assemblyLoader.ScreenshotWriter.Name); } [Test] @@ -141,7 +142,7 @@ public void ShouldThrowExceptionWhenLibAssemblyNotFound() var mockReflectionWrapper = new Mock(); var mockActivationWrapper = new Mock(); var mockGaugeLoadContext = new Mock(); - Assert.Throws(() => new AssemblyLoader(Path.Combine(TmpLocation, $"{_mockLibAssembly.Name}.dll"), mockGaugeLoadContext.Object, + ClassicAssert.Throws(() => new AssemblyLoader(Path.Combine(TmpLocation, $"{_mockLibAssembly.Name}.dll"), mockGaugeLoadContext.Object, mockReflectionWrapper.Object, mockActivationWrapper.Object, new StepRegistry())); } } diff --git a/test/AssemblyLocaterTests.cs b/test/AssemblyLocaterTests.cs index c546540..f79f8da 100644 --- a/test/AssemblyLocaterTests.cs +++ b/test/AssemblyLocaterTests.cs @@ -9,10 +9,11 @@ using System.IO; using System.Linq; using Gauge.CSharp.Core; -using Gauge.Dotnet.Wrappers; using Gauge.Dotnet.Exceptions; +using Gauge.Dotnet.Wrappers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -37,7 +38,7 @@ public void TearDown() public void ShouldGetAssembliesFromGaugeBin() { var expected = "fooAssemblyLocation"; - var expectedAssemblies = new[] {$"{expected}.deps.json"}; + var expectedAssemblies = new[] { $"{expected}.deps.json" }; _mockDirectoryWrapper.Setup(wrapper => wrapper.EnumerateFiles(Utils.GetGaugeBinDir(), "*.deps.json", SearchOption.TopDirectoryOnly)) .Returns(expectedAssemblies); @@ -45,7 +46,7 @@ public void ShouldGetAssembliesFromGaugeBin() var assembly = assemblyLocater.GetTestAssembly(); - Assert.AreEqual($"{expected}.dll", (string)assembly); + ClassicAssert.AreEqual($"{expected}.dll", (string)assembly); } [Test] @@ -56,7 +57,7 @@ public void ShouldNotAddAssembliesFromInvalidFile() .Returns(Enumerable.Empty()); var expectedMessage = $"Could not locate the target test assembly. Gauge-Dotnet could not find a deps.json file in {Directory.GetCurrentDirectory()}"; - Assert.Throws(() => new AssemblyLocater(_mockDirectoryWrapper.Object).GetTestAssembly(), expectedMessage); + ClassicAssert.Throws(() => new AssemblyLocater(_mockDirectoryWrapper.Object).GetTestAssembly(), expectedMessage); } } } \ No newline at end of file diff --git a/test/AssertEx.cs b/test/AssertEx.cs index ffc5b07..4f098e1 100644 --- a/test/AssertEx.cs +++ b/test/AssertEx.cs @@ -8,8 +8,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Runtime.Serialization; -using NUnit.Framework; +using System.Runtime.CompilerServices; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -17,14 +17,14 @@ public static class AssertEx { public static void InheritsFrom() { - Assert.True(typeof(TDerived).IsSubclassOf(typeof(TBase)), + ClassicAssert.True(typeof(TDerived).IsSubclassOf(typeof(TBase)), string.Format("Expected {0} to be a subclass of {1}", typeof(TDerived).FullName, typeof(TBase).FullName)); } public static void DoesNotInheritsFrom() { - Assert.False(typeof(TDerived).IsSubclassOf(typeof(TBase)), + ClassicAssert.False(typeof(TDerived).IsSubclassOf(typeof(TBase)), string.Format("Expected {0} to NOT be a subclass of {1}", typeof(TDerived).FullName, typeof(TBase).FullName)); } @@ -33,13 +33,13 @@ public static void ContainsMethods(IEnumerable methodInfos, params s { var existingMethodNames = methodInfos.Select(info => info.Name).ToArray(); foreach (var methodName in methodNames) - Assert.Contains(methodName, existingMethodNames); + ClassicAssert.Contains(methodName, existingMethodNames); } public static IEnumerable ExecuteProtectedMethod(string methodName, params object[] methodParams) { - var uninitializedObject = FormatterServices.GetUninitializedObject(typeof(T)); - var tags = (IEnumerable) uninitializedObject.GetType() + var uninitializedObject = RuntimeHelpers.GetUninitializedObject(typeof(T)); + var tags = (IEnumerable)uninitializedObject.GetType() .GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic) .Invoke(uninitializedObject, methodParams); return tags; diff --git a/test/CSharpIdentifierTests.cs b/test/CSharpIdentifierTests.cs index c44b4fc..a8022d6 100644 --- a/test/CSharpIdentifierTests.cs +++ b/test/CSharpIdentifierTests.cs @@ -6,6 +6,7 @@ using Gauge.Dotnet.Extensions; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -25,7 +26,7 @@ public class CSharpIdentifierTests [Test] public void GeneratesValidIdentifiers(string input, string expected, bool camelCase) { - Assert.AreEqual(expected, input.ToValidCSharpIdentifier(camelCase)); + ClassicAssert.AreEqual(expected, input.ToValidCSharpIdentifier(camelCase)); } } } \ No newline at end of file diff --git a/test/Converter/StringParamConverterTests.cs b/test/Converter/StringParamConverterTests.cs index f4bbfc8..7f85f84 100644 --- a/test/Converter/StringParamConverterTests.cs +++ b/test/Converter/StringParamConverterTests.cs @@ -9,6 +9,7 @@ using Gauge.Dotnet.Converters; using Gauge.Messages; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Converter { @@ -46,7 +47,7 @@ public void ShouldConvertFromParameterToString() var actual = new StringParamConverter().Convert(parameter); - Assert.AreEqual(expected, actual); + ClassicAssert.AreEqual(expected, actual); } [Test] @@ -55,8 +56,8 @@ public void ShouldTryToConvertStringParameterToBool() var type = new TestTypeConversion().GetType(); var method = type.GetMethod("Bool"); - var getParams = StringParamConverter.TryConvertParams(method, new object[] {"false"}); - Assert.AreEqual(typeof(bool), getParams.First().GetType()); + var getParams = StringParamConverter.TryConvertParams(method, new object[] { "false" }); + ClassicAssert.AreEqual(typeof(bool), getParams.First().GetType()); } [Test] @@ -65,8 +66,8 @@ public void ShouldTryToConvertStringParameterToFloat() var type = new TestTypeConversion().GetType(); var method = type.GetMethod("Float"); - var getParams = StringParamConverter.TryConvertParams(method, new object[] {"3.1412"}); - Assert.AreEqual(typeof(float), getParams.First().GetType()); + var getParams = StringParamConverter.TryConvertParams(method, new object[] { "3.1412" }); + ClassicAssert.AreEqual(typeof(float), getParams.First().GetType()); } [Test] @@ -75,8 +76,8 @@ public void ShouldTryToConvertStringParameterToInt() var type = new TestTypeConversion().GetType(); var method = type.GetMethod("Int"); - var getParams = StringParamConverter.TryConvertParams(method, new object[] {"1"}); - Assert.AreEqual(typeof(int), getParams.First().GetType()); + var getParams = StringParamConverter.TryConvertParams(method, new object[] { "1" }); + ClassicAssert.AreEqual(typeof(int), getParams.First().GetType()); } [Test] @@ -85,8 +86,8 @@ public void ShouldTryToConvertStringParameterToString() var type = new TestTypeConversion().GetType(); var method = type.GetMethod("Int"); - var getParams = StringParamConverter.TryConvertParams(method, new object[] {"hahaha"}); - Assert.AreEqual(typeof(string), getParams.First().GetType()); + var getParams = StringParamConverter.TryConvertParams(method, new object[] { "hahaha" }); + ClassicAssert.AreEqual(typeof(string), getParams.First().GetType()); } } } \ No newline at end of file diff --git a/test/ExecutionOrchestratorTests.cs b/test/ExecutionOrchestratorTests.cs index bbd8da5..eadaaf2 100644 --- a/test/ExecutionOrchestratorTests.cs +++ b/test/ExecutionOrchestratorTests.cs @@ -17,6 +17,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -69,7 +70,7 @@ public void ShouldExecuteHooks() It.IsAny()); mockHookExecuter.VerifyAll(); - Assert.False(result.Failed); + ClassicAssert.False(result.Failed); } [Test] @@ -114,8 +115,8 @@ public void ShouldExecuteHooksAndNotTakeScreenshotOnFailureWhenDisabled() It.IsAny()); mockHookExecuter.VerifyAll(); - Assert.True(result.Failed); - Assert.True(string.IsNullOrEmpty(result.FailureScreenshotFile)); + ClassicAssert.True(result.Failed); + ClassicAssert.True(string.IsNullOrEmpty(result.FailureScreenshotFile)); Environment.SetEnvironmentVariable("SCREENSHOT_ON_FAILURE", screenshotEnabled); } @@ -151,8 +152,8 @@ public void ShouldExecuteMethod() .Returns(pendingScreenshots); var result = orchestrator.ExecuteStep(gaugeMethod, args); mockStepExecutor.VerifyAll(); - Assert.False(result.Failed); - Assert.True(result.ExecutionTime > 0); + ClassicAssert.False(result.Failed); + ClassicAssert.True(result.ExecutionTime > 0); } [Test] @@ -194,7 +195,7 @@ public void ShouldNotTakeScreenShotWhenDisabled() var result = orchestrator.ExecuteStep(gaugeMethod, "Bar", "string"); mockStepExecutor.VerifyAll(); - Assert.True(string.IsNullOrEmpty(result.FailureScreenshotFile)); + ClassicAssert.True(string.IsNullOrEmpty(result.FailureScreenshotFile)); Environment.SetEnvironmentVariable("SCREENSHOT_ON_FAILURE", screenshotEnabled); } @@ -235,8 +236,8 @@ public void ShouldTakeScreenShotOnFailedExecution() mockStepExecutor.VerifyAll(); - Assert.True(result.Failed); - Assert.AreEqual(expectedScreenshot, result.FailureScreenshotFile); + ClassicAssert.True(result.Failed); + ClassicAssert.AreEqual(expectedScreenshot, result.FailureScreenshotFile); } } } \ No newline at end of file diff --git a/test/Extensions/MethodInfoExtensionTests.cs b/test/Extensions/MethodInfoExtensionTests.cs index e77fd79..0a3f9cc 100644 --- a/test/Extensions/MethodInfoExtensionTests.cs +++ b/test/Extensions/MethodInfoExtensionTests.cs @@ -10,6 +10,7 @@ using Gauge.Dotnet.UnitTests.Helpers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Extensions { @@ -41,7 +42,7 @@ public void ShouldGetFullyQualifiedName() .WithStep("Foo") .Build(); - Assert.AreEqual("My.Test.Type.Foo", fooMethod.FullyQuallifiedName()); + ClassicAssert.AreEqual("My.Test.Type.Foo", fooMethod.FullyQuallifiedName()); } [Test] @@ -56,7 +57,7 @@ public void ShouldGetFullyQualifiedNameWithParams() .WithParameters(new KeyValuePair("String", "bar")) .Build(); - Assert.AreEqual("My.Test.Type.Bar-Stringbar", barMethod.FullyQuallifiedName()); + ClassicAssert.AreEqual("My.Test.Type.Bar-Stringbar", barMethod.FullyQuallifiedName()); } [Test] @@ -68,7 +69,7 @@ public void ShouldNotBeRecoverable() .WithStep("Foo") .Build(); - Assert.False(fooMethod.IsRecoverableStep(assemblyLoader.Object)); + ClassicAssert.False(fooMethod.IsRecoverableStep(assemblyLoader.Object)); } [Test] @@ -82,7 +83,7 @@ public void ShouldBeRecoverableWhenContinueOnFailure() .WithParameters(new KeyValuePair("string", "Bar")) .Build(); - Assert.True(barMethod.IsRecoverableStep(assemblyLoader.Object)); + ClassicAssert.True(barMethod.IsRecoverableStep(assemblyLoader.Object)); } [Test] @@ -95,7 +96,7 @@ public void ShouldNotBeRecoverableWhenContinueOnFailureOnNonStep() .WithParameters(new KeyValuePair("string", "Bar")) .Build(); - Assert.False(bazMethod.IsRecoverableStep(assemblyLoader.Object), + ClassicAssert.False(bazMethod.IsRecoverableStep(assemblyLoader.Object), "Recoverable is true only when method is a Step"); } } diff --git a/test/Gauge.Dotnet.UnitTests.csproj b/test/Gauge.Dotnet.UnitTests.csproj index 02b5636..919fb2b 100644 --- a/test/Gauge.Dotnet.UnitTests.csproj +++ b/test/Gauge.Dotnet.UnitTests.csproj @@ -1,14 +1,14 @@  - net7.0 + net8.0 - - - - + + + + diff --git a/test/GaugeCommandFactoryTests.cs b/test/GaugeCommandFactoryTests.cs index 4e3a99f..f35d042 100644 --- a/test/GaugeCommandFactoryTests.cs +++ b/test/GaugeCommandFactoryTests.cs @@ -8,6 +8,7 @@ using System; using System.IO; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -30,14 +31,14 @@ public void TearDown() public void ShouldGetSetupPhaseExecutorForInit() { var command = GaugeCommandFactory.GetExecutor("--init"); - Assert.AreEqual(command.GetType(), typeof(SetupCommand)); + ClassicAssert.AreEqual(command.GetType(), typeof(SetupCommand)); } [Test] public void ShouldGetStartPhaseExecutorByDefault() { var command = GaugeCommandFactory.GetExecutor(default(string)); - Assert.AreEqual(command.GetType(), typeof(StartCommand)); + ClassicAssert.AreEqual(command.GetType(), typeof(StartCommand)); } } } \ No newline at end of file diff --git a/test/HookExecutorTests.cs b/test/HookExecutorTests.cs index 168d092..9732c92 100644 --- a/test/HookExecutorTests.cs +++ b/test/HookExecutorTests.cs @@ -8,14 +8,14 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; using Gauge.Dotnet.Strategy; using Gauge.Dotnet.UnitTests.Helpers; using Gauge.Dotnet.Wrappers; -using Gauge.CSharp.Lib; using Gauge.Messages; using Moq; using NUnit.Framework; -using System.Threading; +using NUnit.Framework.Legacy; using ExecutionContext = Gauge.CSharp.Lib.ExecutionContext; namespace Gauge.Dotnet.UnitTests @@ -38,7 +38,7 @@ public void ShoudExecuteHooks() .WithDeclaringTypeName("my.foo.type") .WithNoParameters() .Build(); - mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List {methodInfo}); + mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List { methodInfo }); mockAssemblyLoader.Setup(x => x.ClassInstanceManagerType).Returns(mockClassInstanceManagerType); var mockReflectionWrapper = new Mock(); @@ -49,14 +49,14 @@ public void ShoudExecuteHooks() mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance, new List())); var mockExecutionInfoMapper = new Mock(); - mockExecutionInfoMapper.Setup(x => x.ExecutionContextFrom(It.IsAny())).Returns(new {}); + mockExecutionInfoMapper.Setup(x => x.ExecutionContextFrom(It.IsAny())).Returns(new { }); var executor = new HookExecutor(mockAssemblyLoader.Object, mockReflectionWrapper.Object, mockClassInstanceManager, mockExecutionInfoMapper.Object); var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), new ExecutionInfo()); - Assert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); + ClassicAssert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); } [Test] @@ -74,7 +74,7 @@ public void ShoudExecuteHooksWithExecutionContext() .WithDeclaringTypeName("my.foo.type") .WithParameters(new KeyValuePair(typeof(ExecutionContext), "context")) .Build(); - mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List {methodInfo}); + mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List { methodInfo }); mockAssemblyLoader.Setup(x => x.ClassInstanceManagerType).Returns(mockClassInstanceManagerType); var executionInfo = new ExecutionInfo(); @@ -97,7 +97,7 @@ public void ShoudExecuteHooksWithExecutionContext() var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), executionInfo); - Assert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); + ClassicAssert.True(result.Success, $"Hook execution failed: {result.ExceptionMessage}\n{result.StackTrace}"); mockReflectionWrapper.VerifyAll(); } @@ -115,7 +115,7 @@ public void ShoudExecuteHooksAndGetTheError() .WithFilteredHook(type) .WithDeclaringTypeName("my.foo.type") .Build(); - mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List {methodInfo}); + mockAssemblyLoader.Setup(x => x.GetMethods(type)).Returns(new List { methodInfo }); mockAssemblyLoader.Setup(x => x.ClassInstanceManagerType).Returns(mockClassInstanceManagerType); var mockReflectionWrapper = new Mock(); @@ -126,7 +126,7 @@ public void ShoudExecuteHooksAndGetTheError() var mockExecutionInfoMapper = new Mock(); mockExecutionInfoMapper.Setup(x => x.ExecutionContextFrom(It.IsAny())) - .Returns(new {Foo = "bar"}); + .Returns(new { Foo = "bar" }); var executor = new HookExecutor(mockAssemblyLoader.Object, mockReflectionWrapper.Object, mockClassInstanceManager, mockExecutionInfoMapper.Object); mockReflectionWrapper.Setup(x => x.Invoke(methodInfo, mockInstance)) @@ -134,8 +134,8 @@ public void ShoudExecuteHooksAndGetTheError() var result = executor.Execute("BeforeSuite", new HooksStrategy(), new List(), new ExecutionInfo()); - Assert.False(result.Success, "Hook execution passed, expected failure"); - Assert.AreEqual(result.ExceptionMessage, "hook failed"); + ClassicAssert.False(result.Success, "Hook execution passed, expected failure"); + ClassicAssert.AreEqual(result.ExceptionMessage, "hook failed"); } } } \ No newline at end of file diff --git a/test/HookRegistryTests.cs b/test/HookRegistryTests.cs index 8193249..c048a53 100644 --- a/test/HookRegistryTests.cs +++ b/test/HookRegistryTests.cs @@ -12,6 +12,7 @@ using Gauge.Dotnet.UnitTests.Helpers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -50,73 +51,73 @@ public void Setup() [Test] public void ShoulddGetAfterScenarioHook() { - var expectedMethods = new[] {"my.foo.type.AfterScenarioHook"}; + var expectedMethods = new[] { "my.foo.type.AfterScenarioHook" }; var hooks = _hookRegistry.AfterScenarioHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetAfterSpecHook() { - var expectedMethods = new[] {"my.foo.type.AfterSpecHook"}; + var expectedMethods = new[] { "my.foo.type.AfterSpecHook" }; var hooks = _hookRegistry.AfterSpecHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetAfterStepHook() { - var expectedMethods = new[] {"my.foo.type.AfterStepHook"}; + var expectedMethods = new[] { "my.foo.type.AfterStepHook" }; var hooks = _hookRegistry.AfterStepHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetAfterSuiteHook() { - var expectedMethods = new[] {"my.foo.type.AfterSuiteHook"}; + var expectedMethods = new[] { "my.foo.type.AfterSuiteHook" }; var hooks = _hookRegistry.AfterSuiteHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetBeforeScenarioHook() { - var expectedMethods = new[] {"my.foo.type.BeforeScenarioHook"}; + var expectedMethods = new[] { "my.foo.type.BeforeScenarioHook" }; var hooks = _hookRegistry.BeforeScenarioHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetBeforeSpecHook() { - var expectedMethods = new[] {"my.foo.type.BeforeSpecHook"}; + var expectedMethods = new[] { "my.foo.type.BeforeSpecHook" }; var hooks = _hookRegistry.BeforeSpecHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetBeforeStepHook() { - var expectedMethods = new[] {"my.foo.type.BeforeStepHook"}; + var expectedMethods = new[] { "my.foo.type.BeforeStepHook" }; var hooks = _hookRegistry.BeforeStepHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } [Test] public void ShouldGetBeforeSuiteHook() { - var expectedMethods = new[] {"my.foo.type.BeforeSuiteHook"}; + var expectedMethods = new[] { "my.foo.type.BeforeSuiteHook" }; var hooks = _hookRegistry.BeforeSuiteHooks.Select(mi => mi.Method); - Assert.AreEqual(expectedMethods, hooks); + ClassicAssert.AreEqual(expectedMethods, hooks); } } } \ No newline at end of file diff --git a/test/Processors/DefaultProcessorTests.cs b/test/Processors/DefaultProcessorTests.cs index f3158ef..4b89301 100644 --- a/test/Processors/DefaultProcessorTests.cs +++ b/test/Processors/DefaultProcessorTests.cs @@ -7,6 +7,7 @@ using Gauge.Dotnet.Processors; using Gauge.Messages; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -25,9 +26,9 @@ public void ShouldProcessMessage() var response = new DefaultProcessor().Process(request); var executionStatusResponse = response.ExecutionStatusResponse; - Assert.AreEqual(response.MessageId, 20); - Assert.AreEqual(response.MessageType, Message.Types.MessageType.ExecutionStatusResponse); - Assert.AreEqual(executionStatusResponse.ExecutionResult.ExecutionTime, 0); + ClassicAssert.AreEqual(response.MessageId, 20); + ClassicAssert.AreEqual(response.MessageType, Message.Types.MessageType.ExecutionStatusResponse); + ClassicAssert.AreEqual(executionStatusResponse.ExecutionResult.ExecutionTime, 0); } } } \ No newline at end of file diff --git a/test/Processors/ExecuteStepProcessorTests.cs b/test/Processors/ExecuteStepProcessorTests.cs index a6bf486..c09641f 100644 --- a/test/Processors/ExecuteStepProcessorTests.cs +++ b/test/Processors/ExecuteStepProcessorTests.cs @@ -10,6 +10,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -51,7 +52,7 @@ public void ShouldProcessExecuteStepRequest() var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); var response = processor.Process(request); - Assert.False(response.ExecutionResult.Failed); + ClassicAssert.False(response.ExecutionResult.Failed); } [Test] @@ -98,7 +99,7 @@ public void ShouldProcessExecuteStepRequestForTableParam(Parameter.Types.Paramet mockOrchestrator.Verify(executor => executor.ExecuteStep(fooMethodInfo, It.Is(strings => strings[0] == tableJSON))); - Assert.False(response.ExecutionResult.Failed); + ClassicAssert.False(response.ExecutionResult.Failed); } [Test] @@ -121,8 +122,8 @@ public void ShouldReportArgumentMismatch() var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); var response = processor.Process(request); - Assert.True(response.ExecutionResult.Failed); - Assert.AreEqual(response.ExecutionResult.ErrorMessage, + ClassicAssert.True(response.ExecutionResult.Failed); + ClassicAssert.AreEqual(response.ExecutionResult.ErrorMessage, "Argument length mismatch for Foo. Actual Count: 0, Expected Count: 1"); } @@ -143,8 +144,8 @@ public void ShouldReportMissingStep() var processor = new ExecuteStepProcessor(mockStepRegistry.Object, mockOrchestrator.Object, mockTableFormatter.Object); var response = processor.Process(request); - Assert.True(response.ExecutionResult.Failed); - Assert.AreEqual(response.ExecutionResult.ErrorMessage, + ClassicAssert.True(response.ExecutionResult.Failed); + ClassicAssert.AreEqual(response.ExecutionResult.ErrorMessage, "Step Implementation not found"); } } diff --git a/test/Processors/ExecutionEndingProcessorTests.cs b/test/Processors/ExecutionEndingProcessorTests.cs index af59c08..f07f1d1 100644 --- a/test/Processors/ExecutionEndingProcessorTests.cs +++ b/test/Processors/ExecutionEndingProcessorTests.cs @@ -6,8 +6,6 @@ using System.Collections.Generic; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -15,6 +13,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -66,10 +65,10 @@ public void Setup() private ExecutionEndingRequest _request; private Mock _mockMethodExecutor; private ProtoExecutionResult _protoExecutionResult; - private readonly IEnumerable _pendingMessages = new List {"Foo", "Bar"}; + private readonly IEnumerable _pendingMessages = new List { "Foo", "Bar" }; private readonly IEnumerable _pendingScreenshotFiles = - new List {"screenshot.png"}; + new List { "screenshot.png" }; [Test] public void ShouldExtendFromHooksExecutionProcessor() @@ -83,7 +82,7 @@ public void ShouldExtendFromHooksExecutionProcessor() public void ShouldGetEmptyTagListByDefault() { var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", _request.CurrentExecutionInfo); - Assert.IsEmpty(tags); + ClassicAssert.IsEmpty(tags); } [Test] @@ -91,8 +90,8 @@ public void ShouldProcessHooks() { var result = _executionEndingProcessor.Process(_request); _mockMethodExecutor.VerifyAll(); - Assert.AreEqual(result.ExecutionResult.Message, _pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles); + ClassicAssert.AreEqual(result.ExecutionResult.Message, _pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles); } diff --git a/test/Processors/ExecutionStartingProcessorTests.cs b/test/Processors/ExecutionStartingProcessorTests.cs index e2d2871..6a454bc 100644 --- a/test/Processors/ExecutionStartingProcessorTests.cs +++ b/test/Processors/ExecutionStartingProcessorTests.cs @@ -6,8 +6,6 @@ using System.Collections.Generic; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -15,6 +13,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -63,7 +62,7 @@ public void Setup() private readonly IEnumerable _pendingMessages = new List { "Foo", "Bar" }; private readonly IEnumerable _pendingScreenshotFiles = - new List { "screenshot.png"}; + new List { "screenshot.png" }; [Test] public void ShouldExtendFromHooksExecutionProcessor() @@ -97,7 +96,7 @@ public void ShouldGetEmptyTagListByDefault() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario); - Assert.IsEmpty(tags); + ClassicAssert.IsEmpty(tags); } [Test] @@ -107,8 +106,8 @@ public void ShouldProcessHooks() var result = _executionStartingProcessor.Process(executionStartingRequest); _mockMethodExecutor.VerifyAll(); - Assert.AreEqual(result.ExecutionResult.Message, _pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles); + ClassicAssert.AreEqual(result.ExecutionResult.Message, _pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles, _pendingScreenshotFiles); } } } \ No newline at end of file diff --git a/test/Processors/HookExecutionProcessorTests.cs b/test/Processors/HookExecutionProcessorTests.cs index f78354a..6248ee1 100644 --- a/test/Processors/HookExecutionProcessorTests.cs +++ b/test/Processors/HookExecutionProcessorTests.cs @@ -16,6 +16,7 @@ using Gauge.Dotnet.Wrappers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -104,34 +105,34 @@ public void ShouldAllowMultipleHooksInaMethod() var beforeScenarioHook = new HookMethod(LibType.BeforeScenario, mockMethod, mockAssemblyLoader.Object); - Assert.AreEqual("MultipleHookMethod", beforeScenarioHook.Method); + ClassicAssert.AreEqual("MultipleHookMethod", beforeScenarioHook.Method); var beforeSpecHook = new HookMethod(LibType.BeforeSpec, mockMethod, mockAssemblyLoader.Object); - Assert.AreEqual("MultipleHookMethod", beforeSpecHook.Method); + ClassicAssert.AreEqual("MultipleHookMethod", beforeSpecHook.Method); } [Test] public void ShouldFetchAHooksWithSpecifiedTagsWhenDoingAnd() { - var applicableHooks = new HooksStrategy().GetTaggedHooks(new List {"Baz", "Bar"}, _hookMethods) + var applicableHooks = new HooksStrategy().GetTaggedHooks(new List { "Baz", "Bar" }, _hookMethods) .ToList(); - Assert.IsNotNull(applicableHooks); - Assert.AreEqual(2, applicableHooks.Count); - Assert.Contains(mockBarMethod.FullyQuallifiedName(), applicableHooks); - Assert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.AreEqual(2, applicableHooks.Count); + ClassicAssert.Contains(mockBarMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); } [Test] public void ShouldFetchAHooksWithSpecifiedTagsWhenDoingOr() { var applicableHooks = - new HooksStrategy().GetTaggedHooks(new List {"Baz", "Foo"}, _hookMethods).ToList(); + new HooksStrategy().GetTaggedHooks(new List { "Baz", "Foo" }, _hookMethods).ToList(); - Assert.IsNotNull(applicableHooks); - Assert.AreEqual(2, applicableHooks.Count); - Assert.Contains(mockFooMethod.FullyQuallifiedName(), applicableHooks); - Assert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.AreEqual(2, applicableHooks.Count); + ClassicAssert.Contains(mockFooMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); } [Test] @@ -139,46 +140,46 @@ public void ShouldFetchAllHooksWhenNoTagsSpecified() { var applicableHooks = new HooksStrategy().GetApplicableHooks(new List(), _hookMethods); - Assert.IsNotNull(applicableHooks); - Assert.AreEqual(1, applicableHooks.Count()); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.AreEqual(1, applicableHooks.Count()); } [Test] public void ShouldFetchAllHooksWithSpecifiedTags() { - var applicableHooks = new HooksStrategy().GetTaggedHooks(new List {"Foo"}, _hookMethods).ToList(); + var applicableHooks = new HooksStrategy().GetTaggedHooks(new List { "Foo" }, _hookMethods).ToList(); - Assert.IsNotNull(applicableHooks); - Assert.AreEqual(2, applicableHooks.Count); - Assert.Contains(mockFooMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.AreEqual(2, applicableHooks.Count); + ClassicAssert.Contains(mockFooMethod.FullyQuallifiedName(), applicableHooks); } [Test] public void ShouldFetchAllHooksWithSpecifiedTagsWhenDoingAnd() { - var applicableHooks = new HooksStrategy().GetTaggedHooks(new List {"Bar"}, _hookMethods); + var applicableHooks = new HooksStrategy().GetTaggedHooks(new List { "Bar" }, _hookMethods); - Assert.IsNotNull(applicableHooks); - Assert.IsEmpty(applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.IsEmpty(applicableHooks); } [Test] public void ShouldFetchAnyHooksWithSpecifiedTagsWhenDoingOr() { - var applicableHooks = new HooksStrategy().GetTaggedHooks(new List {"Baz"}, _hookMethods).ToList(); + var applicableHooks = new HooksStrategy().GetTaggedHooks(new List { "Baz" }, _hookMethods).ToList(); - Assert.IsNotNull(applicableHooks); - Assert.AreEqual(1, applicableHooks.Count); - Assert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.AreEqual(1, applicableHooks.Count); + ClassicAssert.Contains(mockBazMethod.FullyQuallifiedName(), applicableHooks); } [Test] public void ShouldNotFetchAnyTaggedHooksWhenTagsAreASuperSet() { - var applicableHooks = new HooksStrategy().GetTaggedHooks(new List {"Bar", "Blah"}, _hookMethods); + var applicableHooks = new HooksStrategy().GetTaggedHooks(new List { "Bar", "Blah" }, _hookMethods); - Assert.IsNotNull(applicableHooks); - Assert.IsEmpty(applicableHooks); + ClassicAssert.IsNotNull(applicableHooks); + ClassicAssert.IsEmpty(applicableHooks); } [Test] @@ -190,7 +191,7 @@ public void ShouldUseDefaultHooksStrategy() var hooksStrategy = new TestHooksExecutionProcessor(null) .GetHooksStrategy(); - Assert.IsInstanceOf(hooksStrategy); + ClassicAssert.IsInstanceOf(hooksStrategy); } [Test] @@ -203,7 +204,7 @@ public void ShouldUseTaggedHooksFirstStrategy() new TestTaggedHooksFirstExecutionProcessor(null) .GetHooksStrategy(); - Assert.IsInstanceOf(hooksStrategy); + ClassicAssert.IsInstanceOf(hooksStrategy); } [Test] @@ -216,7 +217,7 @@ public void ShouldUseUntaggedHooksFirstStrategy() new TestUntaggedHooksFirstExecutionProcessor(null) .GetHooksStrategy(); - Assert.IsInstanceOf(hooksStrategy); + ClassicAssert.IsInstanceOf(hooksStrategy); } } } \ No newline at end of file diff --git a/test/Processors/ScenarioExecutionEndingProcessorTests.cs b/test/Processors/ScenarioExecutionEndingProcessorTests.cs index 0fb9188..0cdb3ab 100644 --- a/test/Processors/ScenarioExecutionEndingProcessorTests.cs +++ b/test/Processors/ScenarioExecutionEndingProcessorTests.cs @@ -7,13 +7,12 @@ using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -53,10 +52,10 @@ public void ShouldGetTagListFromSpecAndScenario() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(2, tags.Count); - Assert.Contains("foo", tags); - Assert.Contains("bar", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(2, tags.Count); + ClassicAssert.Contains("foo", tags); + ClassicAssert.Contains("bar", tags); } [Test] @@ -85,9 +84,9 @@ public void ShouldNotGetDuplicateTags() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } [Test] @@ -109,7 +108,7 @@ public void ShouldExecutreBeforeScenarioHook() Failed = false }; var pendingMessages = new List { "one", "two" }; - var pendingScreenshotFiles = new List { "screenshot.png" } ; + var pendingScreenshotFiles = new List { "screenshot.png" }; mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterScenario", It.IsAny(), It.IsAny>(), @@ -123,9 +122,9 @@ public void ShouldExecutreBeforeScenarioHook() var processor = new ScenarioExecutionEndingProcessor(mockMethodExecutor.Object); var result = processor.Process(scenarioExecutionStartingRequest); - Assert.False(result.ExecutionResult.Failed); - Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); + ClassicAssert.False(result.ExecutionResult.Failed); + ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); } } } \ No newline at end of file diff --git a/test/Processors/ScenarioExecutionStartingProcessorTests.cs b/test/Processors/ScenarioExecutionStartingProcessorTests.cs index dd5a018..7ea08be 100644 --- a/test/Processors/ScenarioExecutionStartingProcessorTests.cs +++ b/test/Processors/ScenarioExecutionStartingProcessorTests.cs @@ -7,13 +7,12 @@ using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -30,14 +29,14 @@ public void ShouldGetTagListFromExecutionInfo() { var specInfo = new SpecInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { - Tags = {"bar"}, + Tags = { "bar" }, Name = "", IsFailed = false }; @@ -55,10 +54,10 @@ public void ShouldGetTagListFromExecutionInfo() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(2, tags.Count); - Assert.Contains("foo", tags); - Assert.Contains("bar", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(2, tags.Count); + ClassicAssert.Contains("foo", tags); + ClassicAssert.Contains("bar", tags); } [Test] @@ -66,14 +65,14 @@ public void ShouldNotFetchDuplicateTags() { var specInfo = new SpecInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", IsFailed = false }; @@ -87,9 +86,9 @@ public void ShouldNotFetchDuplicateTags() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } [Test] @@ -111,8 +110,8 @@ public void ShouldExecuteBeforeScenarioHook() Failed = false }; - var pendingMessages = new List {"one", "two"}; - var pendingScreenshotFiles = new List {"screenshot.png"}; + var pendingMessages = new List { "one", "two" }; + var pendingScreenshotFiles = new List { "screenshot.png" }; mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeScenario", It.IsAny(), It.IsAny>(), @@ -126,9 +125,9 @@ public void ShouldExecuteBeforeScenarioHook() var processor = new ScenarioExecutionStartingProcessor(mockMethodExecutor.Object); var result = processor.Process(scenarioExecutionEndingRequest); - Assert.False(result.ExecutionResult.Failed); - Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); + ClassicAssert.False(result.ExecutionResult.Failed); + ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); } } } \ No newline at end of file diff --git a/test/Processors/SpecExecutionEndingProcessorTests.cs b/test/Processors/SpecExecutionEndingProcessorTests.cs index 3452258..2b4d9e9 100644 --- a/test/Processors/SpecExecutionEndingProcessorTests.cs +++ b/test/Processors/SpecExecutionEndingProcessorTests.cs @@ -7,13 +7,12 @@ using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -43,9 +42,9 @@ public void ShouldGetTagListFromExecutionInfo() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", executionInfo) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } [Test] @@ -67,7 +66,7 @@ public void ShouldExecuteBeforeSpecHook() }; var pendingMessages = new List { "one", "two" }; - var pendingScreenshotFiles = new List { "screenshot.png"}; + var pendingScreenshotFiles = new List { "screenshot.png" }; mockMethodExecutor.Setup(x => x.ExecuteHooks("AfterSpec", It.IsAny(), It.IsAny>(), @@ -80,9 +79,9 @@ public void ShouldExecuteBeforeSpecHook() var processor = new SpecExecutionEndingProcessor(mockMethodExecutor.Object); var result = processor.Process(request); - Assert.False(result.ExecutionResult.Failed); - Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); + ClassicAssert.False(result.ExecutionResult.Failed); + ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); } } } \ No newline at end of file diff --git a/test/Processors/SpecExecutionStartingProcessorTests.cs b/test/Processors/SpecExecutionStartingProcessorTests.cs index 8bd630f..33f4c2b 100644 --- a/test/Processors/SpecExecutionStartingProcessorTests.cs +++ b/test/Processors/SpecExecutionStartingProcessorTests.cs @@ -7,13 +7,12 @@ using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -30,7 +29,7 @@ public void ShouldGetTagListFromExecutionInfo() { var specInfo = new SpecInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", FileName = "", IsFailed = false @@ -43,9 +42,9 @@ public void ShouldGetTagListFromExecutionInfo() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", executionInfo) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } [Test] @@ -67,8 +66,8 @@ public void ShouldExecutreBeforeSpecHook() ExecutionTime = 0, Failed = false }; - var pendingMessages = new List {"one", "two"}; - var pendingScreenshotFiles = new List {"screenshot.png"}; + var pendingMessages = new List { "one", "two" }; + var pendingScreenshotFiles = new List { "screenshot.png" }; mockMethodExecutor.Setup(x => x.ExecuteHooks("BeforeSpec", It.IsAny(), It.IsAny>(), @@ -82,9 +81,9 @@ public void ShouldExecutreBeforeSpecHook() var processor = new SpecExecutionStartingProcessor(mockMethodExecutor.Object); var result = processor.Process(request); - Assert.False(result.ExecutionResult.Failed); - Assert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); + ClassicAssert.False(result.ExecutionResult.Failed); + ClassicAssert.AreEqual(result.ExecutionResult.Message.ToList(), pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles.ToList(), pendingScreenshotFiles); } } } \ No newline at end of file diff --git a/test/Processors/StepExecutionEndingProcessorTests.cs b/test/Processors/StepExecutionEndingProcessorTests.cs index f96828c..15c33cc 100644 --- a/test/Processors/StepExecutionEndingProcessorTests.cs +++ b/test/Processors/StepExecutionEndingProcessorTests.cs @@ -8,8 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; @@ -17,6 +15,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -90,13 +89,13 @@ public void ShouldReadPendingMessages() { var response = _stepExecutionEndingProcessor.Process(_stepExecutionEndingRequest); - Assert.True(response != null); - Assert.True(response.ExecutionResult != null); - Assert.AreEqual(2, response.ExecutionResult.Message.Count); - Assert.AreEqual(1, response.ExecutionResult.ScreenshotFiles.Count); + ClassicAssert.True(response != null); + ClassicAssert.True(response.ExecutionResult != null); + ClassicAssert.AreEqual(2, response.ExecutionResult.Message.Count); + ClassicAssert.AreEqual(1, response.ExecutionResult.ScreenshotFiles.Count); foreach (var pendingMessage in _pendingMessages) - Assert.Contains(pendingMessage, response.ExecutionResult.Message.ToList()); + ClassicAssert.Contains(pendingMessage, response.ExecutionResult.Message.ToList()); } [Test] @@ -104,14 +103,14 @@ public void ShouldGetTagListFromScenarioAndSpec() { var specInfo = new SpecInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { - Tags = {"bar"}, + Tags = { "bar" }, Name = "", IsFailed = false }; @@ -123,10 +122,10 @@ public void ShouldGetTagListFromScenarioAndSpec() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(2, tags.Count); - Assert.Contains("foo", tags); - Assert.Contains("bar", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(2, tags.Count); + ClassicAssert.Contains("foo", tags); + ClassicAssert.Contains("bar", tags); } [Test] @@ -134,14 +133,14 @@ public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() { var specInfo = new SpecInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", FileName = "", IsFailed = false }; var scenarioInfo = new ScenarioInfo { - Tags = {"foo"}, + Tags = { "foo" }, Name = "", IsFailed = false }; @@ -157,9 +156,9 @@ public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } } } \ No newline at end of file diff --git a/test/Processors/StepExecutionStartingProcessorTests.cs b/test/Processors/StepExecutionStartingProcessorTests.cs index c1dd310..3c9919d 100644 --- a/test/Processors/StepExecutionStartingProcessorTests.cs +++ b/test/Processors/StepExecutionStartingProcessorTests.cs @@ -7,14 +7,13 @@ using System.Collections.Generic; using System.Linq; -using System.Text; -using Gauge.CSharp.Lib; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; using Gauge.Dotnet.Strategy; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -62,8 +61,8 @@ public void ShouldClearExistingGaugeMessages() var processor = new StepExecutionStartingProcessor(mockExecutionHelper.Object); var result = processor.Process(request); - Assert.AreEqual(result.ExecutionResult.Message, pendingMessages); - Assert.AreEqual(result.ExecutionResult.ScreenshotFiles, pendingScreenshotFiles); + ClassicAssert.AreEqual(result.ExecutionResult.Message, pendingMessages); + ClassicAssert.AreEqual(result.ExecutionResult.ScreenshotFiles, pendingScreenshotFiles); } [Test] @@ -90,10 +89,10 @@ public void ShouldGetTagListFromScenarioAndSpec() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(2, tags.Count); - Assert.Contains("foo", tags); - Assert.Contains("bar", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(2, tags.Count); + ClassicAssert.Contains("foo", tags); + ClassicAssert.Contains("bar", tags); } [Test] @@ -124,9 +123,9 @@ public void ShouldGetTagListFromScenarioAndSpecAndIgnoreDuplicates() var tags = AssertEx.ExecuteProtectedMethod("GetApplicableTags", currentScenario) .ToList(); - Assert.IsNotEmpty(tags); - Assert.AreEqual(1, tags.Count); - Assert.Contains("foo", tags); + ClassicAssert.IsNotEmpty(tags); + ClassicAssert.AreEqual(1, tags.Count); + ClassicAssert.Contains("foo", tags); } } } \ No newline at end of file diff --git a/test/Processors/StepNameProcessorTest.cs b/test/Processors/StepNameProcessorTest.cs index 9f8dcbc..81aed38 100644 --- a/test/Processors/StepNameProcessorTest.cs +++ b/test/Processors/StepNameProcessorTest.cs @@ -4,6 +4,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -34,9 +35,9 @@ public void ShouldProcessStepNameRequest() var response = stepNameProcessor.Process(request); - Assert.AreEqual(response.FileName, "foo"); - Assert.AreEqual(response.StepName[0], "step1"); - Assert.False(response.HasAlias); + ClassicAssert.AreEqual(response.FileName, "foo"); + ClassicAssert.AreEqual(response.StepName[0], "step1"); + ClassicAssert.False(response.HasAlias); } [Test] @@ -64,10 +65,10 @@ public void ShouldProcessStepNameWithAliasRequest() var response = stepNameProcessor.Process(request); - Assert.AreEqual(response.FileName, "foo"); - Assert.AreEqual(response.StepName[0], "step2"); - Assert.AreEqual(response.StepName[1], "step3"); - Assert.True(response.HasAlias); + ClassicAssert.AreEqual(response.FileName, "foo"); + ClassicAssert.AreEqual(response.StepName[0], "step2"); + ClassicAssert.AreEqual(response.StepName[1], "step3"); + ClassicAssert.True(response.HasAlias); } [Test] @@ -93,8 +94,8 @@ public void ShouldProcessExternalSteps() var response = stepNameProcessor.Process(request); - Assert.True(response.IsExternal); - // Assert.AreEqual(response.FileName, null); + ClassicAssert.True(response.IsExternal); + // ClassicAssert.AreEqual(response.FileName, null); } } } diff --git a/test/Processors/StepNamesProcessorTests.cs b/test/Processors/StepNamesProcessorTests.cs index 852ab5c..cc4b91a 100644 --- a/test/Processors/StepNamesProcessorTests.cs +++ b/test/Processors/StepNamesProcessorTests.cs @@ -4,6 +4,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -13,12 +14,12 @@ public class StepNamesProcessorTests public void ShouldProcessStepNamesRequest() { var mockStepRegistry = new Mock(); - mockStepRegistry.Setup(r => r.GetStepTexts()).Returns(new List {"step1", "step2", "step3"}); + mockStepRegistry.Setup(r => r.GetStepTexts()).Returns(new List { "step1", "step2", "step3" }); var stepNamesProcessor = new StepNamesProcessor(mockStepRegistry.Object); var request = new StepNamesRequest(); var response = stepNamesProcessor.Process(request); - Assert.AreEqual(3, response.Steps.Count); - Assert.AreEqual(response.Steps[0], "step1"); + ClassicAssert.AreEqual(3, response.Steps.Count); + ClassicAssert.AreEqual(response.Steps[0], "step1"); } } } \ No newline at end of file diff --git a/test/Processors/StepPositionsProcessorTests.cs b/test/Processors/StepPositionsProcessorTests.cs index d48a53f..d40ea3c 100644 --- a/test/Processors/StepPositionsProcessorTests.cs +++ b/test/Processors/StepPositionsProcessorTests.cs @@ -5,15 +5,13 @@ *----------------------------------------------------------------*/ -using System.Collections.Generic; using System.Linq; -using System.Xml.Linq; using Gauge.Dotnet.Models; using Gauge.Dotnet.Processors; -using Gauge.Dotnet.Wrappers; using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; using static Gauge.Messages.StepPositionsResponse.Types; namespace Gauge.Dotnet.UnitTests.Processors @@ -26,15 +24,15 @@ public void ShouldProcessRequest() var filePath = "Foo.cs"; var mockStepRegistry = new Mock(); mockStepRegistry.Setup(x => x.GetStepPositions(filePath)) - .Returns(new[] {new StepPosition{StepValue = "goodbye", Span = new Span{Start= 6, End= 16}}}); + .Returns(new[] { new StepPosition { StepValue = "goodbye", Span = new Span { Start = 6, End = 16 } } }); var processor = new StepPositionsProcessor(mockStepRegistry.Object); - var request = new StepPositionsRequest {FilePath = "Foo.cs"}; + var request = new StepPositionsRequest { FilePath = "Foo.cs" }; var response = processor.Process(request); - Assert.AreEqual(response.StepPositions.Count, 1); - Assert.AreEqual(response.StepPositions.First().StepValue, "goodbye"); - Assert.AreEqual(response.StepPositions.First().Span.Start, 6); + ClassicAssert.AreEqual(response.StepPositions.Count, 1); + ClassicAssert.AreEqual(response.StepPositions.First().StepValue, "goodbye"); + ClassicAssert.AreEqual(response.StepPositions.First().Span.Start, 6); } @@ -49,11 +47,11 @@ public void ShouldProcessRequestForAliasSteps() new StepPosition{StepValue = "Sayonara", Span = new Span{Start= 6, End= 16}}, }); var processor = new StepPositionsProcessor(mockStepRegistry.Object); - var request = new StepPositionsRequest {FilePath = filePath}; + var request = new StepPositionsRequest { FilePath = filePath }; var response = processor.Process(request); - Assert.AreEqual(response.StepPositions.Count, 2); + ClassicAssert.AreEqual(response.StepPositions.Count, 2); } } } \ No newline at end of file diff --git a/test/Processors/TaggedHooksFirstStrategyTests.cs b/test/Processors/TaggedHooksFirstStrategyTests.cs index eeefcf5..bfacca7 100644 --- a/test/Processors/TaggedHooksFirstStrategyTests.cs +++ b/test/Processors/TaggedHooksFirstStrategyTests.cs @@ -13,6 +13,7 @@ using Gauge.Dotnet.UnitTests.Helpers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -87,36 +88,36 @@ IHookMethod Create(string name, int aggregation = 0, params string[] tags) [Test] public void ShouldFetchTaggedHooksInSortedOrder() { - var untaggedHooks = new[] {"my.foo.type.Blah", "my.foo.type.Zed"}; + var untaggedHooks = new[] { "my.foo.type.Blah", "my.foo.type.Zed" }; var applicableHooks = new TaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToArray(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToArray(); var actual = new ArraySegment(applicableHooks, 2, untaggedHooks.Count()); - Assert.AreEqual(untaggedHooks, actual); + ClassicAssert.AreEqual(untaggedHooks, actual); } [Test] public void ShouldFetchUntaggedHooksAfterTaggedHooks() { - var taggedHooks = new[] {"my.foo.type.Baz", "my.foo.type.Foo"}; - var untaggedHooks = new[] {"my.foo.type.Blah", "my.foo.type.Zed"}; + var taggedHooks = new[] { "my.foo.type.Baz", "my.foo.type.Foo" }; + var untaggedHooks = new[] { "my.foo.type.Blah", "my.foo.type.Zed" }; var expected = taggedHooks.Concat(untaggedHooks); var applicableHooks = new TaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToList(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToList(); - Assert.AreEqual(expected, applicableHooks); + ClassicAssert.AreEqual(expected, applicableHooks); } [Test] public void ShouldFetchUntaggedHooksInSortedOrder() { var applicableHooks = new TaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToList(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToList(); - Assert.That(applicableHooks[0], Is.EqualTo("my.foo.type.Baz")); - Assert.That(applicableHooks[1], Is.EqualTo("my.foo.type.Foo")); + ClassicAssert.That(applicableHooks[0], Is.EqualTo("my.foo.type.Baz")); + ClassicAssert.That(applicableHooks[1], Is.EqualTo("my.foo.type.Foo")); } } } \ No newline at end of file diff --git a/test/Processors/UntaggedHooksFirstStrategyTests.cs b/test/Processors/UntaggedHooksFirstStrategyTests.cs index 773fa79..3d2c190 100644 --- a/test/Processors/UntaggedHooksFirstStrategyTests.cs +++ b/test/Processors/UntaggedHooksFirstStrategyTests.cs @@ -12,6 +12,7 @@ using Gauge.Dotnet.UnitTests.Helpers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests.Processors { @@ -88,7 +89,7 @@ IHookMethod Create(string name, int aggregation = 0, params string[] tags) public void ShouldFetchTaggedHooksAfterUntaggedHooks() { var applicableHooks = new UntaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToList(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToList(); var expectedMethods = new[] { @@ -99,14 +100,14 @@ public void ShouldFetchTaggedHooksAfterUntaggedHooks() }; - Assert.AreEqual(expectedMethods, applicableHooks); + ClassicAssert.AreEqual(expectedMethods, applicableHooks); } [Test] public void ShouldFetchTaggedHooksInSortedOrder() { var applicableHooks = new UntaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToList(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToList(); var expectedMethods = new[] { @@ -116,17 +117,17 @@ public void ShouldFetchTaggedHooksInSortedOrder() "my.foo.type.Foo" }; - Assert.AreEqual(expectedMethods, applicableHooks); + ClassicAssert.AreEqual(expectedMethods, applicableHooks); } [Test] public void ShouldFetchUntaggedHooksInSortedOrder() { var applicableHooks = new UntaggedHooksFirstStrategy() - .GetApplicableHooks(new List {"Foo"}, _hookMethods).ToList(); + .GetApplicableHooks(new List { "Foo" }, _hookMethods).ToList(); - Assert.AreEqual(applicableHooks[2], "my.foo.type.Zed"); - Assert.AreEqual(applicableHooks[3], "my.foo.type.Foo"); + ClassicAssert.AreEqual(applicableHooks[2], "my.foo.type.Zed"); + ClassicAssert.AreEqual(applicableHooks[3], "my.foo.type.Foo"); } } } \ No newline at end of file diff --git a/test/StartCommandTests.cs b/test/StartCommandTests.cs index 58c48a0..2a0a680 100644 --- a/test/StartCommandTests.cs +++ b/test/StartCommandTests.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Hosting; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -26,8 +27,8 @@ public FakeGaugeListener(IConfiguration configuration) : base(configuration) { } - public override void ConfigureServices(IServiceCollection services) {} - public override void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime) {} + public override void ConfigureServices(IServiceCollection services) { } + public override void Configure(IApplicationBuilder app, IHostApplicationLifetime lifetime) { } } [SetUp] @@ -53,7 +54,8 @@ public void TearDown() [Test] public void ShouldInvokeProjectBuild() { - _startCommand.Execute().ContinueWith(b => { + _startCommand.Execute().ContinueWith(b => + { _mockGaugeProjectBuilder.Verify(builder => builder.BuildTargetGaugeProject(), Times.Once); }); } @@ -62,7 +64,8 @@ public void ShouldInvokeProjectBuild() public void ShouldNotBuildWhenCustomBuildPathIsSetAsync() { Environment.SetEnvironmentVariable("GAUGE_CUSTOM_BUILD_PATH", "GAUGE_CUSTOM_BUILD_PATH"); - _startCommand.Execute().ContinueWith(b => { + _startCommand.Execute().ContinueWith(b => + { _mockGaugeProjectBuilder.Verify(builder => builder.BuildTargetGaugeProject(), Times.Never); }); @@ -73,7 +76,7 @@ public void ShouldNotPollForMessagesWhenBuildFails() { _mockGaugeProjectBuilder.Setup(builder => builder.BuildTargetGaugeProject()).Returns(false); _startCommand.Execute() - .ContinueWith(b => Assert.False(b.Result, "Should not start server when build fails")); + .ContinueWith(b => ClassicAssert.False(b.Result, "Should not start server when build fails")); } [Test] @@ -82,7 +85,7 @@ public void ShouldPollForMessagesWhenBuildPasses() _mockGaugeProjectBuilder.Setup(builder => builder.BuildTargetGaugeProject()).Returns(true); _startCommand.Execute() - .ContinueWith(b => Assert.True(b.Result, "Should start server using GaugeListener when build passes")); + .ContinueWith(b => ClassicAssert.True(b.Result, "Should start server using GaugeListener when build passes")); } [Test] @@ -91,7 +94,7 @@ public void ShouldPollForMessagesWhenCustomBuildPathIsSet() Environment.SetEnvironmentVariable("GAUGE_CUSTOM_BUILD_PATH", "GAUGE_CUSTOM_BUILD_PATH"); _startCommand.Execute() - .ContinueWith(b => Assert.True(b.Result, "Should start server using GaugeListener when GAUGE_CUSTOM_BUILD_PATH is set")); + .ContinueWith(b => ClassicAssert.True(b.Result, "Should start server using GaugeListener when GAUGE_CUSTOM_BUILD_PATH is set")); } [Test] @@ -103,7 +106,7 @@ public void ShouldRunProcessInProjectRoot() if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) expected = $"/private{expected}"; - Assert.That(actual, Is.SamePath(expected)); + ClassicAssert.That(actual, Is.SamePath(expected)); } } } \ No newline at end of file diff --git a/test/StaticLoaderTests.cs b/test/StaticLoaderTests.cs index f70c2ea..a2cf31f 100644 --- a/test/StaticLoaderTests.cs +++ b/test/StaticLoaderTests.cs @@ -14,6 +14,7 @@ using Gauge.Dotnet.Wrappers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -58,9 +59,9 @@ public void ShouldAddAliasesSteps() loader.LoadStepsFromText(text, fileName); var registry = loader.GetStepRegistry(); - Assert.True(registry.ContainsStep("goodbye")); - Assert.True(registry.ContainsStep("adieu")); - Assert.True(registry.ContainsStep("sayonara")); + ClassicAssert.True(registry.ContainsStep("goodbye")); + ClassicAssert.True(registry.ContainsStep("adieu")); + ClassicAssert.True(registry.ContainsStep("sayonara")); } [Test] @@ -85,7 +86,7 @@ public void ShouldAddStepsFromGivenContent() "}\n"; const string fileName = @"foo.cs"; loader.LoadStepsFromText(text, fileName); - Assert.True(loader.GetStepRegistry().ContainsStep("hello")); + ClassicAssert.True(loader.GetStepRegistry().ContainsStep("hello")); } [Test] @@ -128,9 +129,9 @@ public void ShouldLoadStepsWithPosition() loader.ReloadSteps(newText, file2); var positions = loader.GetStepRegistry().GetStepPositions(file1).ToList(); - Assert.AreEqual(1, positions.Count); - Assert.AreEqual(6, positions.First().Span.Start); - Assert.AreEqual(9, positions.First().Span.End); + ClassicAssert.AreEqual(1, positions.Count); + ClassicAssert.AreEqual(6, positions.First().Span.Start); + ClassicAssert.AreEqual(9, positions.First().Span.End); } [Test] @@ -160,7 +161,7 @@ public void ShouldNotReloadStepOfRemovedFile() const string fileName = @"foo.cs"; var filePath = Path.Combine(Utils.GaugeProjectRoot, fileName); loader.ReloadSteps(text, filePath); - Assert.False(loader.GetStepRegistry().ContainsStep("hello")); + ClassicAssert.False(loader.GetStepRegistry().ContainsStep("hello")); Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", null); } @@ -185,7 +186,7 @@ public void ShouldReloadSteps() "}\n"; const string fileName = @"foo.cs"; loader.LoadStepsFromText(text, fileName); - Assert.True(loader.GetStepRegistry().ContainsStep("hello")); + ClassicAssert.True(loader.GetStepRegistry().ContainsStep("hello")); const string newText = "using Gauge.CSharp.Lib.Attributes;\n" + "namespace foobar\n" + @@ -205,7 +206,7 @@ public void ShouldReloadSteps() loader.ReloadSteps(newText, fileName); - Assert.True(loader.GetStepRegistry().ContainsStep("hola")); + ClassicAssert.True(loader.GetStepRegistry().ContainsStep("hola")); } [Test] @@ -247,12 +248,12 @@ public void ShouldRemoveSteps() loader.ReloadSteps(newText, file2); - Assert.True(loader.GetStepRegistry().ContainsStep("hello")); - Assert.True(loader.GetStepRegistry().ContainsStep("hola")); + ClassicAssert.True(loader.GetStepRegistry().ContainsStep("hello")); + ClassicAssert.True(loader.GetStepRegistry().ContainsStep("hola")); loader.RemoveSteps(file2); - Assert.False(loader.GetStepRegistry().ContainsStep("hola")); + ClassicAssert.False(loader.GetStepRegistry().ContainsStep("hola")); } public class LoadImplementationsTest diff --git a/test/StepExecutorTests.cs b/test/StepExecutorTests.cs index 881d842..d3492d9 100644 --- a/test/StepExecutorTests.cs +++ b/test/StepExecutorTests.cs @@ -12,6 +12,7 @@ using Gauge.Dotnet.Wrappers; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -51,7 +52,7 @@ public void ShoudExecuteStep() var result = executor.Execute(gaugeMethod); - Assert.True(result.Success); + ClassicAssert.True(result.Success); } [Test] @@ -86,8 +87,8 @@ public void ShoudExecuteStepAndGetFailure() .Throws(new Exception("step execution failure")); var result = executor.Execute(gaugeMethod); - Assert.False(result.Success); - Assert.AreEqual(result.ExceptionMessage, "step execution failure"); + ClassicAssert.False(result.Success); + ClassicAssert.AreEqual(result.ExceptionMessage, "step execution failure"); } [Test] @@ -124,9 +125,9 @@ public void ShoudExecuteStepAndGetRecoverableError() .Throws(new Exception("step execution failure")); var result = executor.Execute(gaugeMethod); - Assert.False(result.Success); - Assert.True(result.Recoverable); - Assert.AreEqual(result.ExceptionMessage, "step execution failure"); + ClassicAssert.False(result.Success); + ClassicAssert.True(result.Recoverable); + ClassicAssert.AreEqual(result.ExceptionMessage, "step execution failure"); } } } \ No newline at end of file diff --git a/test/StepRegistryTests.cs b/test/StepRegistryTests.cs index 22a4bef..ce5e1b5 100644 --- a/test/StepRegistryTests.cs +++ b/test/StepRegistryTests.cs @@ -9,6 +9,7 @@ using System.Linq; using Gauge.Dotnet.Models; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -27,8 +28,8 @@ public void ShouldContainMethodForStepDefined() foreach (var pair in methods) stepRegistry.AddStep(pair.Key, pair.Value); - Assert.True(stepRegistry.ContainsStep("Foo")); - Assert.True(stepRegistry.ContainsStep("Bar")); + ClassicAssert.True(stepRegistry.ContainsStep("Foo")); + ClassicAssert.True(stepRegistry.ContainsStep("Bar")); } [Test] @@ -57,7 +58,7 @@ public void ShouldGetAliasWhenExists() foreach (var pair in methods) stepRegistry.AddStep(pair.Key, pair.Value); - Assert.True(stepRegistry.HasAlias("foo {}")); + ClassicAssert.True(stepRegistry.HasAlias("foo {}")); } [Test] @@ -74,9 +75,9 @@ public void ShouldGetAllSteps() var allSteps = stepRegistry.AllSteps().ToList(); - Assert.AreEqual(allSteps.Count, 2); - Assert.True(allSteps.Contains("Foo")); - Assert.True(allSteps.Contains("Bar")); + ClassicAssert.AreEqual(allSteps.Count, 2); + ClassicAssert.True(allSteps.Contains("Foo")); + ClassicAssert.True(allSteps.Contains("Bar")); } [Test] @@ -91,7 +92,7 @@ public void ShouldGetEmptyStepTextForInvalidParameterizedStepText() foreach (var pair in methods) stepRegistry.AddStep(pair.Key, pair.Value); - Assert.AreEqual(stepRegistry.GetStepText("random"), string.Empty); + ClassicAssert.AreEqual(stepRegistry.GetStepText("random"), string.Empty); } [Test] @@ -108,7 +109,7 @@ public void ShouldGetMethodForStep() var method = stepRegistry.MethodFor("Foo"); - Assert.AreEqual(method.Name, "Foo"); + ClassicAssert.AreEqual(method.Name, "Foo"); } [Test] @@ -130,7 +131,7 @@ public void ShouldGetStepTextFromParameterizedStepText() stepRegistry.AddStep(pair.Key, pair.Value); - Assert.AreEqual(stepRegistry.GetStepText("Foo {}"), "Foo "); + ClassicAssert.AreEqual(stepRegistry.GetStepText("Foo {}"), "Foo "); } [Test] @@ -147,8 +148,8 @@ public void ShouldNotHaveAliasWhenSingleStepTextIsDefined() foreach (var pair in methods) stepRegistry.AddStep(pair.Key, pair.Value); - Assert.False(stepRegistry.HasAlias("Foo")); - Assert.False(stepRegistry.HasAlias("Bar")); + ClassicAssert.False(stepRegistry.HasAlias("Foo")); + ClassicAssert.False(stepRegistry.HasAlias("Bar")); } [Test] @@ -166,30 +167,30 @@ public void ShouldRemoveStepsDefinedInAGivenFile() stepRegistry.AddStep(pair.Key, pair.Value); stepRegistry.RemoveSteps("Foo.cs"); - Assert.False(stepRegistry.ContainsStep("Foo")); + ClassicAssert.False(stepRegistry.ContainsStep("Foo")); } [Test] public void ShouldCheckIfFileIsCached() { var stepRegistry = new StepRegistry(); - stepRegistry.AddStep("Foo", new GaugeMethod {Name = "Foo", StepText = "Foo", FileName = "Foo.cs"}); + stepRegistry.AddStep("Foo", new GaugeMethod { Name = "Foo", StepText = "Foo", FileName = "Foo.cs" }); - Assert.True(stepRegistry.IsFileCached("Foo.cs")); - Assert.False(stepRegistry.IsFileCached("Bar.cs")); + ClassicAssert.True(stepRegistry.IsFileCached("Foo.cs")); + ClassicAssert.False(stepRegistry.IsFileCached("Bar.cs")); } [Test] public void ShouldNotContainStepPositionForExternalSteps() { var stepRegistry = new StepRegistry(); - stepRegistry.AddStep("Foo", new GaugeMethod {Name = "Foo", StepText = "Foo", FileName = "foo.cs"}); - stepRegistry.AddStep("Bar", new GaugeMethod {Name = "Bar", StepText = "Bar", IsExternal = true}); + stepRegistry.AddStep("Foo", new GaugeMethod { Name = "Foo", StepText = "Foo", FileName = "foo.cs" }); + stepRegistry.AddStep("Bar", new GaugeMethod { Name = "Bar", StepText = "Bar", IsExternal = true }); var positions = stepRegistry.GetStepPositions("foo.cs"); - Assert.True(positions.Count() == 1); - Assert.AreNotEqual(positions.First().StepValue, "Bar"); + ClassicAssert.True(positions.Count() == 1); + ClassicAssert.AreNotEqual(positions.First().StepValue, "Bar"); } } } \ No newline at end of file diff --git a/test/UtilsTest.cs b/test/UtilsTest.cs index c7a0d17..51c4a69 100644 --- a/test/UtilsTest.cs +++ b/test/UtilsTest.cs @@ -9,6 +9,7 @@ using System.IO; using Gauge.CSharp.Core; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -23,7 +24,7 @@ public void ShouldGetCustomBuildPathFromEnvWhenLowerCase() var imaginaryPath = string.Format("Foo{0}Bar", Path.DirectorySeparatorChar); Environment.SetEnvironmentVariable("gauge_custom_build_path", imaginaryPath); var gaugeBinDir = Utils.GetGaugeBinDir(); - Assert.AreEqual(string.Format(@"C:\Blah{0}Foo{0}Bar", Path.DirectorySeparatorChar), gaugeBinDir); + ClassicAssert.AreEqual(string.Format(@"C:\Blah{0}Foo{0}Bar", Path.DirectorySeparatorChar), gaugeBinDir); Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", string.Empty); Environment.SetEnvironmentVariable("GAUGE_CUSTOM_BUILD_PATH", string.Empty); @@ -39,7 +40,7 @@ public void ShouldGetCustomBuildPathFromEnvWhenUpperCase() ; Environment.SetEnvironmentVariable("gauge_custom_build_path", imaginaryPath); var gaugeBinDir = Utils.GetGaugeBinDir(); - Assert.AreEqual(Path.Combine(driveRoot, "Blah", "Foo", "Bar"), gaugeBinDir); + ClassicAssert.AreEqual(Path.Combine(driveRoot, "Blah", "Foo", "Bar"), gaugeBinDir); Environment.SetEnvironmentVariable("GAUGE_PROJECT_ROOT", string.Empty); Environment.SetEnvironmentVariable("GAUGE_CUSTOM_BUILD_PATH", string.Empty); diff --git a/test/ValidateProcessorTests.cs b/test/ValidateProcessorTests.cs index 9a6cb5e..7967559 100644 --- a/test/ValidateProcessorTests.cs +++ b/test/ValidateProcessorTests.cs @@ -9,6 +9,7 @@ using Gauge.Messages; using Moq; using NUnit.Framework; +using NUnit.Framework.Legacy; namespace Gauge.Dotnet.UnitTests { @@ -21,7 +22,7 @@ public void Setup() _mockStepRegistry = new Mock(); } - + private Mock _mockStepRegistry; [Test] @@ -38,12 +39,12 @@ public void ShouldGetErrorResponseForStepValidateRequestWhenMultipleStepImplFoun var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); - Assert.AreEqual(false, response.IsValid); - Assert.AreEqual(StepValidateResponse.Types.ErrorType.DuplicateStepImplementation, + ClassicAssert.AreEqual(false, response.IsValid); + ClassicAssert.AreEqual(StepValidateResponse.Types.ErrorType.DuplicateStepImplementation, response.ErrorType); - Assert.AreEqual("Multiple step implementations found for : step_text_1", + ClassicAssert.AreEqual("Multiple step implementations found for : step_text_1", response.ErrorMessage); - Assert.IsEmpty(response.Suggestion); + ClassicAssert.IsEmpty(response.Suggestion); } [Test] @@ -62,8 +63,8 @@ public void ShouldGetErrorResponseForStepValidateRequestWhennNoImplFound() var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); - Assert.AreEqual(false, response.IsValid); - Assert.AreEqual(StepValidateResponse.Types.ErrorType.StepImplementationNotFound, + ClassicAssert.AreEqual(false, response.IsValid); + ClassicAssert.AreEqual(StepValidateResponse.Types.ErrorType.StepImplementationNotFound, response.ErrorType); StringAssert.Contains("No implementation found for : step_text_1.", response.ErrorMessage); @@ -86,7 +87,7 @@ public void ShouldGetVaildResponseForStepValidateRequest() var processor = new StepValidationProcessor(_mockStepRegistry.Object); var response = processor.Process(request); - Assert.AreEqual(true, response.IsValid); + ClassicAssert.AreEqual(true, response.IsValid); } } } \ No newline at end of file