Exemplo n.º 1
0
        public void Go_AsksForFirstNumberFirst_UsingMoq()
        {
            // Arrange
            var mockScreen = new Mock <IScreen>();
            var mockKeypad = new Mock <IKeypad>();
            var queue      = new Queue <string>(new[] { "5", "*", "2" });

            mockKeypad.Setup(keypad => keypad.GetInput()).Returns(() => queue.Dequeue());

            var calculatorInterface = new CalculatorInterface(mockScreen.Object, mockKeypad.Object);

            // Act
            calculatorInterface.Go();

            // Assert
            mockScreen.Verify(screen => screen.Print("Enter your first number"));
            mockScreen.Verify(screen => screen.Print("Enter the operator"));
            mockScreen.Verify(screen => screen.Print("Enter your Second Number"));
            mockScreen.Verify(screen => screen.Print("Result is 10"));
        }
Exemplo n.º 2
0
        public void Go_AsksForFirstNumberFirst()
        {
            // Arrange
            var screen = new FakeScreen();
            var keypad = new FakeKeypad();

            keypad.Messages = new List <string>
            {
                "5",
                "2",
                "*",
            };

            var calculatorInterface = new CalculatorInterface(screen, keypad);

            // Act
            calculatorInterface.Go();

            // Assert
            Assert.Equal("Enter your first number", screen.Messages[0]);
        }