public async Task CommandParametersExtention_BindingCompleted_IsCalled() { var rootCommand = new RootCommand(); rootCommand.AddOption(new Option("--otheroption") { Argument = new Argument <bool>() }); var context = new InvocationContext(new Parser(rootCommand).Parse("--otheroption"), Substitute.For <IConsole>()); var testParams = new TestArguments2(); testParams.Extensions.Add(testParams.Args); var sut = new PretzelCommandHandler( Substitute.For <IConfiguration>(), testParams, new ExportFactory <Logic.Commands.ICommand, CommandInfoAttribute>( () => Tuple.Create( Substitute.For <Logic.Commands.ICommand>(), new Action(() => { }) ), new CommandInfoAttribute())); await sut.InvokeAsync(context); Assert.True(testParams.Args.BindingCompletedCalled); }
public void ParseVerbWithNotMandatoryAndWithBooleanDefaultOption_WorksFineIfSpecified() { //******** GIVEN string[] arguments = new string[] { @"/storage --d='C:\Temp\Pluto' --r" }; Exception thrownEx = null; //******** WHEN TestArguments2 parsed = this._Parser.UseAggregatedArguments().Parse <TestArguments2>(arguments); //******** ASSERT thrownEx = this._Parser.GetLastError(); string message = thrownEx == null ? "" : thrownEx.Message; Assert.IsNull(thrownEx, message); Assert.IsNotNull(parsed.Repository, "Wrong value for Repository"); Assert.IsTrue(parsed.Repository.Recreate, "Wrong value for Recreate"); }
public void ParseVerbWithNotMandatoryAndWithDefaultOption_WorksFine() { //******** GIVEN string[] arguments = new string[] { @"/storage --d='C:\Temp\Pluto'" }; Exception thrownEx = null; //******** WHEN TestArguments2 parsed = this._Parser.UseAggregatedArguments().Parse <TestArguments2>(arguments); //******** ASSERT thrownEx = this._Parser.GetLastError(); string message = thrownEx == null ? "" : thrownEx.Message; Assert.IsNull(thrownEx, message); Assert.IsNotNull(parsed.Repository, "Wrong value for Repository"); Assert.IsFalse(String.IsNullOrEmpty(parsed.Repository.FileName), "Wrong value for FileName: cannot be null"); Assert.AreEqual("MyData.dat", parsed.Repository.FileName, "Wrong value for FileName"); }