Esempio n. 1
0
        public void TestNonSatisfiedVerbosityWriteNotRecordLastMessage()
        {
            var mockInput       = new Mock <IInput>();
            var mockErrorOutput = new Mock <IOutput>();
            var mockOutput      = new Mock <IOutputConsole>();

            mockOutput.Setup((o) => o.Options)
            .Returns(OutputOptions.VerbosityNormal | OutputOptions.OutputPlain);

            mockOutput.Setup((o) => o.GetErrorOutput())
            .Returns(mockErrorOutput.Object);

            var ioConsole = new IOConsole(mockInput.Object, mockOutput.Object);

            ioConsole.WriteError("foo", false);
            ioConsole.WriteError("foo bar baz", true, Verbosities.Debug);
            ioConsole.OverwriteError("bar", false);

            mockErrorOutput.Verify((o) => o.Write("foo", false, OutputOptions.VerbosityNormal), Times.Once());
            mockErrorOutput.Verify((o) => o.Write("foo bar baz", true, OutputOptions.VerbosityDebug), Times.Once());
            mockErrorOutput.Verify((o) => o.Write("\x08\x08\x08", false, OutputOptions.VerbosityNormal), Times.Once());
            mockErrorOutput.Verify((o) => o.Write("bar", false, OutputOptions.VerbosityNormal), Times.Once());
        }
Esempio n. 2
0
        public void TestWriteError()
        {
            var mockInput  = new Mock <IInput>();
            var mockOutput = new Mock <IOutputConsole>();

            mockOutput.Setup((o) => o.Options)
            .Returns(OutputOptions.VerbosityNormal);

            mockOutput.Setup((o) => o.GetErrorOutput())
            .Returns(mockOutput.Object);

            var ioConsole = new IOConsole(mockInput.Object, mockOutput.Object);

            ioConsole.WriteError("foo bar menghanyu zzz", true);

            mockOutput.Verify((o) => o.Write("foo bar menghanyu zzz", true, OutputOptions.VerbosityNormal));
        }