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); }
public void Add() { IAdds iadd = new Adds(); Arithmetic arithmetic = new Arithmetic(iadd); int res = arithmetic.Add(1, 2); Assert.Equal(3, res); }
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); }
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); }