public void ExecuteCommand_WithNoVerb_WritesResponse() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd"); Assert.IsTrue(testWriter.Contains("The command 'cmd' requires a verb.")); }
public void ExecuteCommand_WithInvalidVerb_WritesResponse() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd not"); Assert.IsTrue(testWriter.Contains("No verb with the specified name 'not' exists.")); }
public void ExecuteCommand_ProcessesException() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd x"); Assert.IsTrue(testWriter.Contains("TEST MESSAGE") && testWriter.Contains("System.NullReferenceException")); }
public void ConvertParameter_ConvertsType_Failure5() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd typeTest --bool1 --bool2 yes --bool3 no --bool4 on --bool5 off --bool6 true --int1 123 --int2 132 --int3 123 --int4 123 --int5 gbg"); Assert.IsFalse(testWriter.Contains("SUCCESS")); }
public void ExecuteCommand_WithNoOptionalFlag_ExecutesCommand() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd opt"); Assert.IsTrue(testWriter.Contains("OPTIONAL")); }
public void ConvertParameter_ConvertsType_Success() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd typeTest --bool1 --bool2 yes --bool3 no --bool4 on --bool5 off --bool6 true --int1 \"-123\" --int2 65535 --int3 123 --int4 123.43 --int5 423123"); Assert.IsTrue(testWriter.Contains("SUCCESS")); }
public void BasicCommand_WithInvalidParamType_WritesMessage() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd some --a bah"); Assert.IsTrue(testWriter.Contains("Unable to convert the operand 'a' with the value 'bah' to the expected type value 'System.Boolean'.")); }
public void BasicCommand_PerformsAction_Coverage5() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd some -v -x"); Assert.IsTrue(testWriter.Contains("The verb 'some' requires a different combination of operands than what was provided.")); }
public void BasicCommand_PerformsAction_Coverage4() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd some -v"); Assert.IsTrue(testWriter.Contains("NOTHING")); }
public void ExecuteCommand_WithDefaultValue_Coverage() { var c = new InvalidInternals(); underTest.AddCommand(c); var handled = false; underTest.CommandExceptionEncountered += (o, a) => handled = true; underTest.ExecuteCommand("cmd not value"); Assert.IsFalse(handled); }
public void DuplicateOperand_WritesError() { var c = new InvalidInternals(); underTest.AddCommand(c); underTest.ExecuteCommand("cmd v --f temp --f"); Assert.IsTrue(testWriter.Contains("Duplicate operand or flag names are not allowed!")); Assert.IsFalse(testWriter.Contains("NOTHING")); }
public void ExecuteCommand_Handler_ProcessesException() { var c = new InvalidInternals(); underTest.AddCommand(c); var handled = false; EventHandler <TerminalCommandExceptionEventArgs> handler = (o, a) => handled = true; underTest.CommandExceptionEncountered += handler; underTest.ExecuteCommand("cmd x2"); underTest.CommandExceptionEncountered -= handler; Assert.IsTrue(handled); }