Beispiel #1
0
        public void MockAdd()
        {
            var mockIAdd = new Mock <IAdds>();

            mockIAdd.Setup(m => m.Add(1, 2)).Returns(2);
            Arithmetic arithmetic = new Arithmetic(mockIAdd.Object);
            int        res        = arithmetic.Add(1, 2);

            Assert.Equal(2, res);
            res = arithmetic.Add(1, 4);//
            Assert.Equal(0, res);
        }
Beispiel #2
0
        public void Add()
        {
            IAdds      iadd       = new Adds();
            Arithmetic arithmetic = new Arithmetic(iadd);
            int        res        = arithmetic.Add(1, 2);

            Assert.Equal(3, res);
        }
Beispiel #3
0
        public void AddMuItiple(int parmaA, int parmaB)
        {
            IAdds      iadd       = new Adds();
            Arithmetic arithmetic = new Arithmetic(iadd);
            int        res        = arithmetic.Add(parmaA, parmaB);

            Assert.Equal(parmaA + parmaB, res);
        }
Beispiel #4
0
        public void MockAnyAdd()
        {
            var mockIAdd = new Mock <IAdds>();

            mockIAdd.Setup(m => m.Add(It.IsAny <int>(), It.IsAny <int>())).Returns(4);
            Arithmetic arithmetic = new Arithmetic(mockIAdd.Object);
            int        res        = arithmetic.Add(1, 2);

            Assert.Equal(4, res);
        }