public void TestOverwrite() { var mockInput = new Mock <IInput>(); var mockOutput = new Mock <IOutput>(); mockOutput.Setup((o) => o.Options) .Returns(OutputOptions.VerbosityNormal); mockOutput.Setup((o) => o.Formatter) .Returns(new OutputFormatter()); var ioConsole = new IOConsole(mockInput.Object, mockOutput.Object); ioConsole.Write("something (<question>strlen = 23</question>)"); ioConsole.Overwrite("shorter (<comment>12</comment>)", false); ioConsole.Overwrite("something longer than initial (<info>34</info>)", false); mockOutput.Verify((o) => o.Write("something (<question>strlen = 23</question>)", true, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write(Str.Repeat("\x08", 23), false, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write("shorter (<comment>12</comment>)", false, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write(Str.Repeat(11), false, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write(Str.Repeat("\x08", 11), false, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write(Str.Repeat("\x08", 12), false, OutputOptions.VerbosityNormal), Times.Once()); mockOutput.Verify((o) => o.Write("something longer than initial (<info>34</info>)", false, OutputOptions.VerbosityNormal), Times.Once()); }
public void TestWrite() { var mockInput = new Mock <IInput>(); var mockOutput = new Mock <IOutput>(); mockOutput.Setup((o) => o.Options) .Returns(OutputOptions.VerbosityNormal); var ioConsole = new IOConsole(mockInput.Object, mockOutput.Object); ioConsole.Write("foo bar menghanyu zzz", true); mockOutput.Verify((o) => o.Write("foo bar menghanyu zzz", true, OutputOptions.VerbosityNormal)); }
public void TestWriteWithDebugging() { var mockInput = new Mock <IInput>(); var mockOutput = new Mock <IOutput>(); mockOutput.Setup((o) => o.Options) .Returns(OutputOptions.VerbosityNormal); var ioConsole = new IOConsole(mockInput.Object, mockOutput.Object); var stopwatch = new Stopwatch(); ioConsole.SetDebugging(stopwatch); stopwatch.Start(); ioConsole.Write("hello world", true); mockOutput.Verify((o) => o.Write(It.IsRegex(@"^\[(.*)/(.*)\] hello world$"), true, OutputOptions.VerbosityNormal)); }