public async Task TwoArgsWithOptionTest() { { var args = "-n foo -r 3".Split(' '); var log = new LogStack(); await new HostBuilder() .ConfigureTestLogging(testOutput, log, true) .RunConsoleAppFrameworkAsync <TwoArgsWithOption>(args); log.InfoLogShouldBe(0, "name:foo"); log.InfoLogShouldBe(1, "repeat:3"); } { var log = new LogStack(); using (TextWriterBridge.BeginSetConsoleOut(testOutput, log)) { var args = new string[0]; await new HostBuilder().RunConsoleAppFrameworkAsync <TwoArgsWithOption>(args); var strAssertion = log.ToStringInfo().Should(); strAssertion.Contain("Options:"); // ok to show help strAssertion.Contain("-n"); strAssertion.Contain("name of this"); strAssertion.Contain("-r"); strAssertion.Contain("repeat msg"); } } }
public async Task SimpleTwoArgsTest() { { var args = "-name foo -repeat 3".Split(' '); var log = new LogStack(); await new HostBuilder() .ConfigureTestLogging(testOutput, log, true) .RunConsoleAppFrameworkAsync <SimpleTwoArgs>(args); log.InfoLogShouldBe(0, "name:foo"); log.InfoLogShouldBe(1, "repeat:3"); } { var args = "-repeat 3".Split(' '); var log = new LogStack(); var ex = await Assert.ThrowsAsync <AggregateException>(async() => { await new HostBuilder() .ConfigureTestLogging(testOutput, log, true) .RunConsoleAppFrameworkAsync <SimpleTwoArgs>(args); }); ex.Flatten().InnerException.Should().BeAssignableTo <TestLogException>() .Subject.InnerException.Message.Should().Contain("Required parameter \"name\" not found in argument"); } { var log = new LogStack(); using (TextWriterBridge.BeginSetConsoleOut(testOutput, log)) { var args = new string[0]; await new HostBuilder().RunConsoleAppFrameworkAsync <SimpleTwoArgs>(args); log.ToStringInfo().Should().Contain("Options:"); // ok to show help } } }
public async Task SimpleTwoArgsTest() { { var args = "-name foo -repeat 3".Split(' '); var log = new LogStack(); await new HostBuilder() .ConfigureTestLogging(testOutput, log, true) .RunConsoleAppFrameworkAsync <SimpleTwoArgs>(args); log.InfoLogShouldBe(0, "name:foo"); log.InfoLogShouldBe(1, "repeat:3"); } { //var args = "-repeat 3".Split(' '); //var log = new LogStack(); //using (TextWriterBridge.BeginSetConsoleOut(testOutput, log)) //{ // { // await new HostBuilder() // .ConfigureTestLogging(testOutput, log, true) // .RunConsoleAppFrameworkAsync<SimpleTwoArgs>(args); // } // log.ToStringInfo().Should().Contain("Required parameter \"name\" not found in argument"); //} } { var log = new LogStack(); using (TextWriterBridge.BeginSetConsoleOut(testOutput, log)) { var args = new string[0]; await new HostBuilder().RunConsoleAppFrameworkAsync <SimpleTwoArgs>(args); log.ToStringInfo().Should().Contain("Options:"); // ok to show help } } }