public void When_NoneValidCommand_Then_ReturnNull() { //set up repl with console var console = new Console(); var repl = new Ui.Repl.Repl(console, new DummyCommand()); //Assert if returned result is null Assert.Null(repl.ComputeInput("").Result); }
public void When_ValidVersionCommand_Then_ShowVersion() { // Set up repl with mock console var writer = new TestTextWriter(); var console = new TestConsole(writer, new TestTextReader()); var repl = new Ui.Repl.Repl(console, new RootCommand(new TestApplicationLifecycle(), console)); //Compute version input repl.ComputeInput("version"); // Assert if correct version is printed var content = writer.Content; Assert.Contains(Constants.McsmVersion, content); }
public void When_ValidHelpCommand_Then_ShowHelp() { // Set up repl with mock console var writer = new TestTextWriter(); var console = new TestConsole(writer, new TestTextReader()); var repl = new Ui.Repl.Repl(console, new RootCommand(new TestApplicationLifecycle(), console)); // Compute help input repl.ComputeInput("help"); // Assert that "Usage:", "help", "Shows information about all commands" is included in res var content = writer.Content; Assert.Contains("Usage:", content); Assert.Contains("h, help", content); Assert.Contains("Shows information about all commands", content); }
public void When_ValidExitCommand_Then_Exit() { //Set up mock console var writer = new TestTextWriter(); var console = new TestConsole(writer, new TestTextReader()); //Set up mock application life cycle var stopped = false; var testLifecycle = new TestApplicationLifecycle(stopDel: () => { stopped = true; }); //Set up repl var repl = new Ui.Repl.Repl(console, new RootCommand(testLifecycle, console)); //Compute exit input repl.ComputeInput("exit"); //Assert if stop method was called Assert.True(stopped); }