public void TestPayBillNoSuchBill() { var billManagerMock = new Mock <IBillManager>(); billManagerMock.Setup(m => m.GetBill(It.IsAny <int>())) .Returns <Bill>(null); var billAPI = new BillAPI(billManagerMock.Object, null); var result = billAPI.PayBill(1, 100); Assert.AreEqual(BillErrorCodes.NoSuchBill, result); billManagerMock.Verify(m => m.PayBill(It.IsAny <Bill>(), It.IsAny <int>()), Times.Never); }
public void TestPayBillExactAmount() { var billManagerMock = new Mock <IBillManager>(); billManagerMock.Setup(m => m.GetBill(It.IsAny <int>())) .Returns(new Bill { BillID = 1, Amount = 100 }); var billAPI = new BillAPI(billManagerMock.Object, null); var result = billAPI.PayBill(1, 100); Assert.AreEqual(BillErrorCodes.okTheWholeBillIsPayed, result); billManagerMock.Verify(m => m.PayBill(It.IsAny <Bill>(), It.IsAny <double>()), Times.Once); }
public void TestPayBillTooLargeAmount() { var billManagerMock = new Mock <IBillManager>(); billManagerMock.Setup(m => m.GetBill(It.IsAny <int>())) .Returns(new Bill { BillID = 1, Amount = 100 }); var billAPI = new BillAPI(billManagerMock.Object, null); var result = billAPI.PayBill(1, 101); Assert.AreEqual(BillErrorCodes.ToLargeAmount, result); billManagerMock.Verify(m => m.PayBill(It.IsAny <Bill>(), It.IsAny <int>()), Times.Never); }