Ejemplo n.º 1
0
        public void MathOneAddsTwoNumbers()
        {
            // Mocking the behaviour of the interface
            var testOnMock = new Mock <ITestOne>();

            testOnMock.Setup(x => x.Add(10, 10)).Returns(20);
            var mathOne = new MathOne(testOnMock.Object);       // extract the object from the mock object

            Assert.Equal(20, mathOne.Add(10, 10));
        }
Ejemplo n.º 2
0
        public void VerifyFunctionHasBeenCalled()
        {
            // Mocking the behaviour of the interface
            var testOnMock = new Mock <ITestOne>();
            var msg        = "Hello Web";

            var mathOne = new MathOne(testOnMock.Object);

            mathOne.Out(msg);

            testOnMock.Verify(x => x.Out(msg), Times.Once);
        }