예제 #1
0
        public void TestThatPromptsAreObserved()
        {
            const string prompt = "[Prompt!] ";

            var reader    = Substitute.For <IConsoleReader>();
            var lineInput = Substitute.For <IConsoleLineInput>();

            lineInput.Prompt = prompt;
            reader.LineInput.Returns(lineInput);

            var client = new ConsoleLoopClient(reader);

            client.Prompt.Should().Be(prompt);

            const string newPrompt = "NewPrompt";

            client.Prompt = newPrompt;
            client.Prompt.Should().Be(newPrompt);
            lineInput.Prompt.ToString().Should().Be(newPrompt);

            client.DisplayPrompt();
            lineInput.Received(1).DisplayPrompt();
        }
예제 #2
0
        public void TestThatColoredPromptsAreObserved()
        {
            var prompt = new ColoredString("[Prompt!] ", ConsoleColor.Cyan);

            var reader    = Substitute.For <IConsoleReader>();
            var lineInput = Substitute.For <IConsoleLineInput>();

            lineInput.Prompt = prompt;
            reader.LineInput.Returns(lineInput);

            var client = new ConsoleLoopClient(reader);

            client.Prompt.Should().Be(prompt);

            var newPrompt = new ColoredString("NewPrompt", ConsoleColor.Green);

            client.PromptWithColor = newPrompt;
            client.PromptWithColor.Should().Be(newPrompt);
            client.Prompt.Should().Be(newPrompt.ToString());
            lineInput.Prompt.Should().Be(newPrompt);

            client.DisplayPrompt();
            lineInput.Received(1).DisplayPrompt();
        }