public void CallAsyncMethodsCorrectly2() { var hw = new TestAsyncApp(); var exitCode = Sidi.GetOpt.GetOpt.Run(hw, new[] { "TestAsyncWithStringResult" }); Assert.IsTrue(hw.TestAsyncWasCalled); Assert.AreEqual(0, exitCode); }
public void HandleExceptionsInAsyncMethodsCorrectly() { using (var c = new CaptureConsoleOutput()) { var hw = new TestAsyncApp(); var exitCode = Sidi.GetOpt.GetOpt.Run(hw, new[] { "TestAsyncWithException" }); Assert.IsTrue(hw.TestAsyncWasCalled); Assert.AreEqual(-1, exitCode); StringAssert.Contains(TestAsyncApp.anErrorOccured, c.error.ToString()); } }
public void CustomExceptionHandler() { using (var c = new CaptureConsoleOutput()) { var hw = new TestAsyncApp(); var go = new Sidi.GetOpt.GetOpt { Application = hw, Arguments = new[] { "TestAsyncWithException" }, OnException = (e) => - 123 }; var exitCode = go.Run(); Assert.IsTrue(hw.TestAsyncWasCalled); Assert.AreEqual(-123, exitCode); } }