Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }