public void Execute_HandleError_Registered_ValidationError() { var sample = new ValidationSample_01(); var p = new Parser<ValidationSample_01>(); var handled = false; p.RegisterErrorHandler(ex => { handled = true; }, false); p.Run(new[] { "morethan5", "/n=1" }, sample); Assert.IsTrue(handled); }
public void Execute_HandleError_Registered_UnhandledParameters() { var mock = new Mock<IPrinter>(); var sample = new Sample_02 { Printer = mock.Object }; var p = new Parser<Sample_02>(); var handled = false; p.RegisterErrorHandler(ex => { handled = true; }, false); p.Run(new[] { "-count:1", "-message:a", "-prefix:p", "-upper", "-what:x" }, sample); Assert.IsTrue(handled); }
public void Execute_HandleError_Registered_NoRethrow() { var p = new Parser<Sample_39>(); var handled = false; p.RegisterErrorHandler(ex => { handled = true; }, false); p.Run(new string[] { }); Assert.IsTrue(handled); }
public void Execute_HandleError_Registered_Rethrow() { var p = new Parser<Sample_39>(); var handled = false; p.RegisterErrorHandler(ex => { handled = true; }, true); try { p.Run(new string[] { }); Assert.Fail(); } catch (Exception) { Assert.IsTrue(handled); } }
public void RegisterError_MoreThanOne_Exception() { var p = new Parser<Sample_02>(); p.RegisterErrorHandler(delegate { }); p.RegisterErrorHandler(delegate { }); }