예제 #1
0
        public void Input_WhenCalled_CallsReaderOnce()
        {
            //Arrange
            var reader = new Mock <IReader>();
            var writer = new Mock <IWriter>();

            reader.Setup(x => x.ReadLine()).Returns("2");
            var commandFactory = new Mock <ICommandFactory>();
            var menu           = new FakeMenu(reader.Object, writer.Object, commandFactory.Object);

            //Act
            menu.Input();

            //Assert
            reader.Verify(x => x.ReadLine(), Times.Once());
        }
예제 #2
0
        public void Input_ReadInvalidValue_CallsWriteOnce()
        {
            //Arrange
            var reader = new Mock <IReader>();
            var writer = new Mock <IWriter>();

            reader.Setup(x => x.ReadLine()).Returns("e");
            var commandFactory = new Mock <ICommandFactory>();
            var menu           = new FakeMenu(reader.Object, writer.Object, commandFactory.Object);

            //Act
            menu.Input();

            //Assert
            writer.Verify(x => x.WriteLine("Incorect input value"), Times.Once());
        }