コード例 #1
0
        public void ShouldProvideCorrectCalculationResults()
        {
            // Arrange
            IOutputWriter writerMock = new TestOutputWriter();
            IInputReader  readerMock = new TestInputReader();
            var           cut        = new CustomLogicComponent(readerMock, writerMock);

            // Act
            cut.DivideExample();

            // Assert
            Assert.IsTrue(((TestOutputWriter)writerMock)
                          .DoesItReceive("The result is: 2"), "Calculation is incorrect." + ((TestOutputWriter)writerMock).ReceivedCalls());
        }
コード例 #2
0
        public void ShouldReadSecondArgument()
        {
            // Arrange
            IOutputWriter writerMock = new TestOutputWriter();
            IInputReader  readerMock = new TestInputReader();
            var           sut        = new CustomLogicComponent(readerMock, writerMock);

            // Act
            sut.DivideExample();

            // Assert
            Assert.IsTrue(((TestOutputWriter)writerMock)
                          .DoesItReceive("Enter another number to be divided"), "Second phrase is incorrrect");
            Assert.AreEqual(2,
                            ((TestInputReader)readerMock).GetReadLineCallsCount());
        }