public void PromptsUserBeforeExiting() { // arrange var console = new Mock<IConsole>(); console.Setup(x => x.ReadLine(message)).Returns("n"); var executor = new Mock<IRepl>(); var cmd = new ExitCommand(console.Object); // act cmd.Execute(executor.Object, null); // assert console.Verify(x => x.ReadLine(message)); }
public void DoesNotExitWhenUserAnswersNo() { // arrange var console = new Mock<IConsole>(); console.Setup(x => x.ReadLine()).Returns("n"); var executor = new Mock<IRepl>(); var cmd = new ExitCommand(console.Object); // act cmd.Execute(executor.Object, null); // assert executor.Verify(x => x.Terminate(), Times.Never); }
public void ExitsWhenUserAnswersYes() { // arrange var console = new Mock<IConsole>(); console.Setup(x => x.ReadLine(message)).Returns("y"); var executor = new Mock<IRepl>(); var cmd = new ExitCommand(console.Object); // act cmd.Execute(executor.Object, null); // assert executor.Verify(x => x.Terminate()); }
public void PromptsUserBeforeExiting() { // arrange const string message = "Are you sure you wish to exit? (y/n): "; var console = new Mock<IConsole>(); console.Setup(x => x.ReadLine()).Returns("n"); var executor = new Mock<IRepl>(); var cmd = new ExitCommand(console.Object); // act cmd.Execute(executor.Object, null); // assert console.Verify(x => x.Write(message)); }