Пример #1
0
        public void ItCanBeWrittenTo()
        {
            var inout = new MockInputOutput();

            // Act
            inout.Write("Text");
        }
Пример #2
0
        public void ItCanBeReadFrom()
        {
            var inout = new MockInputOutput();

            inout.InFeed.Enqueue("Test");

            // Act
            var input = inout.ReadLine();
        }
Пример #3
0
        public void ItCanWriteABlankLine()
        {
            // Arrange
            var inout = new MockInputOutput();

            // Act
            inout.WriteLine();

            // Assert
            Assert.Single(inout.OutFeed);
            Assert.Equal(Environment.NewLine, inout.OutFeed.First());
        }
Пример #4
0
        public void ProvidedInputCanBeRetrieved()
        {
            // Arrange
            var inout = new MockInputOutput();

            inout.InFeed.Enqueue("Test");

            // Act
            var input = inout.ReadLine();

            // Assert
            Assert.Equal("Test", input);
        }
Пример #5
0
        public void WrittenTextCanBeRetrieved()
        {
            // Arrange
            var inout = new MockInputOutput();

            inout.Write("Text");

            // Act
            var writtenText = inout.OutFeed;

            // Assert
            Assert.Single(writtenText);
            Assert.Equal("Text", writtenText.First());
        }
Пример #6
0
        public void ProvidedInputCanBeRetrievedInSuccession()
        {
            // Arrange
            var inout = new MockInputOutput();

            inout.InFeed.Enqueue("Test 1");
            inout.InFeed.Enqueue("Test 2");

            // Act
            var input1 = inout.ReadLine();
            var input2 = inout.ReadLine();

            // Assert
            Assert.Equal("Test 1", input1);
            Assert.Equal("Test 2", input2);
        }
Пример #7
0
        public void StandardTestRun()
        {
            // Arrange
            var inout = new MockInputOutput();
            var rand  = new MockRandomGenerator();
            var game  = new Mastermind(inout, rand);

            // Arrange - Inputs
            rand.SetLetters('A', 'B', 'C', 'F');
            inout.InFeed.Enqueue("AAA");
            inout.InFeed.Enqueue("AAAA");
            inout.InFeed.Enqueue("ABBB");
            inout.InFeed.Enqueue("ABCC");
            inout.InFeed.Enqueue("ABCD");
            inout.InFeed.Enqueue("ABCF");
            inout.InFeed.Enqueue(" ");

            // Arrange - Outputs
            var expectedOutputs = new Queue <string>();

            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("Password length is 4." + Environment.NewLine);
            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("+---" + Environment.NewLine);
            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("++--" + Environment.NewLine);
            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("+++-" + Environment.NewLine);
            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("+++" + Environment.NewLine);
            expectedOutputs.Enqueue("Take a guess: ");
            expectedOutputs.Enqueue("++++" + Environment.NewLine);
            expectedOutputs.Enqueue("Congratulations you guessed the password in 6 tries." + Environment.NewLine);

            // Act
            game.Play();

            // Assert
            inout.OutFeed.ForEach(text =>
            {
                Assert.Equal(expectedOutputs.Dequeue(), text);
            });
        }
Пример #8
0
 public void ItExists()
 {
     var inout = new MockInputOutput();
 }