diff --git a/Directory.Packages.props b/Directory.Packages.props index 6ce3c99..2f93b91 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + @@ -36,7 +36,6 @@ - diff --git a/src/CommandLine/src/Application/AutomationConsoleApplication.cs b/src/CommandLine/src/Application/AutomationConsoleApplication.cs index 3d30310..a2725e8 100644 --- a/src/CommandLine/src/Application/AutomationConsoleApplication.cs +++ b/src/CommandLine/src/Application/AutomationConsoleApplication.cs @@ -3,8 +3,6 @@ // Licensed under the MIT License // ------------------------------------------------------- -using System.CommandLine; - namespace AutomationIoC.CommandLine.Application; internal class AutomationConsoleApplication( @@ -13,8 +11,8 @@ internal class AutomationConsoleApplication( { private readonly string[] arguments = arguments ?? Environment.GetCommandLineArgs(); - public int Run() => new CommandLineConfiguration(rootCommand).Invoke(arguments); + public int Run() => rootCommand.Parse(arguments).Invoke(); public Task RunAsync(CancellationToken cancellationToken = default) => - new CommandLineConfiguration(rootCommand).InvokeAsync(arguments, cancellationToken); + rootCommand.Parse(arguments).InvokeAsync(cancellationToken: cancellationToken); } diff --git a/src/CommandLine/test/AutomationCommandTests.cs b/src/CommandLine/test/AutomationCommandTests.cs index 6ee1c9a..f9e2449 100644 --- a/src/CommandLine/test/AutomationCommandTests.cs +++ b/src/CommandLine/test/AutomationCommandTests.cs @@ -72,9 +72,10 @@ public void CreateCommand_ShouldCreateCommandWithAutomationContext() actualConfigurationValue = testService.GetConfigurationValue(configurationKey); }); - new CommandLineConfiguration(command).Invoke(commandName); + int result = command.Parse(commandName).Invoke(); // Assert + Assert.Equal(0, result); Assert.Equal(configurationValue, actualConfigurationValue); } @@ -124,10 +125,11 @@ await testService .ConfigureAwait(false); }); - await new CommandLineConfiguration(command) - .InvokeAsync(commandName, TestContext.Current.CancellationToken); + int result = await command.Parse(commandName) + .InvokeAsync(cancellationToken: TestContext.Current.CancellationToken); // Assert + Assert.Equal(0, result); Assert.Equal(configurationValue, actualConfigurationValue); } @@ -202,10 +204,12 @@ await testService // Act AutomationCommand.Clone(source: commandOne, target: commandTwo); - await new CommandLineConfiguration(commandTwo) - .InvokeAsync([commandTwoName, "--optionOne", commandOptionValue], TestContext.Current.CancellationToken); + int result = await commandTwo + .Parse([commandTwoName, "--optionOne", commandOptionValue]) + .InvokeAsync(cancellationToken: TestContext.Current.CancellationToken); // Assert + Assert.Equal(0, result); Assert.Equal(configurationValue, actualConfigurationValue); Assert.Equal(commandOptionValue, actualOptionValue); Assert.Equivalent(commandOne.Options, commandTwo.Options); diff --git a/src/CommandLine/test/AutomationIoC.CommandLine.Test.csproj b/src/CommandLine/test/AutomationIoC.CommandLine.Test.csproj index 480bd4a..f50b43a 100644 --- a/src/CommandLine/test/AutomationIoC.CommandLine.Test.csproj +++ b/src/CommandLine/test/AutomationIoC.CommandLine.Test.csproj @@ -20,7 +20,6 @@ - diff --git a/src/CommandLine/test/Builder/AutomationConsoleBuilderTests.cs b/src/CommandLine/test/Builder/AutomationConsoleBuilderTests.cs index 0839a87..82f637c 100644 --- a/src/CommandLine/test/Builder/AutomationConsoleBuilderTests.cs +++ b/src/CommandLine/test/Builder/AutomationConsoleBuilderTests.cs @@ -7,7 +7,6 @@ using AutomationIoC.CommandLine.Test.TestBed.Commands; using AutomationIoC.CommandLine.Test.TestBed.Services; using AutomationIoC.Runtime.Context; -using FluentAssertions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; @@ -31,11 +30,11 @@ public void ShouldBuildCommandsWithAddCommand() // Act int invocationResult = - new CommandLineConfiguration(configuredRootCommand) - .Invoke(["test", "subcommand", "--optionOne", "testValue"]); + configuredRootCommand.Parse(["test", "subcommand", "--optionOne", "testValue"]) + .Invoke(); // Assert - invocationResult.Should().Be(0); + Assert.Equal(0, invocationResult); } [Fact] @@ -72,11 +71,11 @@ public void ShouldBuildCommandsWithAutomationContext() // Act int invocationResult = - new CommandLineConfiguration(configuredRootCommand) - .Invoke(["full-test", "--key", expectedKey]); + configuredRootCommand.Parse(["full-test", "--key", expectedKey]) + .Invoke(); // Assert - invocationResult.Should().Be(0); + Assert.Equal(0, invocationResult); testServiceMock.Verify(service => service.Execute(expectedKeyValue), Times.Once); } @@ -120,7 +119,7 @@ public void ShouldBuildAutomationConsoleApplication() automationConsoleBuilder.Build().Run(); // Assert - invocationResult.Should().Be(0); + Assert.Equal(0, invocationResult); testServiceMock.Verify(service => service.Execute(expectedKeyValue), Times.Once); } } diff --git a/src/PowerShell/PowerShell/test/AutomationIoC.PowerShell.Test.csproj b/src/PowerShell/PowerShell/test/AutomationIoC.PowerShell.Test.csproj index a987499..d31928c 100644 --- a/src/PowerShell/PowerShell/test/AutomationIoC.PowerShell.Test.csproj +++ b/src/PowerShell/PowerShell/test/AutomationIoC.PowerShell.Test.csproj @@ -19,7 +19,6 @@ - diff --git a/src/PowerShell/Tools/README.md b/src/PowerShell/Tools/README.md index 171d2f9..676b408 100644 --- a/src/PowerShell/Tools/README.md +++ b/src/PowerShell/Tools/README.md @@ -108,7 +108,6 @@ Sample Test ```csharp using AutomationIoC.PSCmdlets.Tools; -using FluentAssertions; using Xunit; public class RequestCardTests @@ -138,7 +137,7 @@ public class RequestCardTests var actualTestData = submitDataCommand.RunCommand().First(); - actualTestData.Should().BeEquivalentTo(expectedTestData); + Assert.Equivalent(expectedTestData, actualTestData); } } ``` diff --git a/src/Runtime/test/AutomationIoC.Runtime.Test.csproj b/src/Runtime/test/AutomationIoC.Runtime.Test.csproj index 30daaa0..c5aba6b 100644 --- a/src/Runtime/test/AutomationIoC.Runtime.Test.csproj +++ b/src/Runtime/test/AutomationIoC.Runtime.Test.csproj @@ -20,7 +20,6 @@ - diff --git a/src/Runtime/test/Dependency/DependencyFactoryTests.cs b/src/Runtime/test/Dependency/DependencyFactoryTests.cs index f6cbe1a..0a8fbe3 100644 --- a/src/Runtime/test/Dependency/DependencyFactoryTests.cs +++ b/src/Runtime/test/Dependency/DependencyFactoryTests.cs @@ -3,7 +3,6 @@ // Licensed under the MIT License // ------------------------------------------------------- -using FluentAssertions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -29,11 +28,8 @@ public void GenerateServiceProvider_ShouldBuildRuntimeProviderFromSession() IServiceProvider actualServiceProvider = DependencyFactory.GenerateServiceProvider(sessionStorage, startup); // Assert - actualServiceProvider.GetRequiredService() - .Should().BeEquivalentTo(sessionStorage); - - actualServiceProvider.GetRequiredService() - .Should().BeEquivalentTo(startup); + Assert.Equivalent(sessionStorage, actualServiceProvider.GetRequiredService()); + Assert.Equivalent(startup, actualServiceProvider.GetRequiredService()); Assert.NotNull(actualServiceProvider.GetService()); Assert.NotNull(actualServiceProvider.GetService()); @@ -49,8 +45,7 @@ public void GenerateServiceProvider_ShouldBuildRuntimeProviderFromSessionStatPro IServiceProvider actualServiceProvider = DependencyFactory.GenerateServiceProvider(sessionStorage); // Assert - actualServiceProvider.GetRequiredService() - .Should().BeEquivalentTo(sessionStorage); + Assert.Equivalent(sessionStorage, actualServiceProvider.GetRequiredService()); } [Fact]