Ejemplo n.º 1
0
        public async Task Should_Be_Able_To_Get_No_Due_To_Bill_Giving_PayDate_Less_Then_DueDateAsync()
        {
            mockRepository.Setup(e => e.AddBill(It.IsAny <Bill>()));

            var service = new BillsToPayService(mockRepository.Object);

            var billReturn = await service.AddBill(new BillDTO
            {
                Name          = "Water",
                OriginalPrice = 100,
                DueDate       = new DateTime(2020, 10, 10),
                PayDate       = new DateTime(2020, 10, 9)
            });

            mockRepository.Verify(e => e.AddBill(It.Is <Bill>(e => e.Name == "Water" && e.Interest == 0 && e.Fine == 0)), Times.AtLeastOnce());
        }
Ejemplo n.º 2
0
        public async Task Should_Be_Able_To_Calculate_ActualPrice_Giving_Zero_Due_And_InterestAsync()
        {
            IEnumerable <Bill> stub = new List <Bill>()
            {
                Bill.Of("Light", 100m, new DateTime(2020, 10, 10), new DateTime(2020, 10, 10))
            };

            mockRepository.Setup(e => e.GetBills())
            .Returns(Task.FromResult(stub));

            var service = new BillsToPayService(mockRepository.Object);
            var bills   = await service.GetBills();

            Assert.True(bills.ToList().Count > 0);
            Assert.Equal(bills.ToList()[0].ActualPrice, 100m);
        }
Ejemplo n.º 3
0
        public async Task Should_Be_Able_To_Get_No_Due_To_Bill_Giving_PayDate_Between_3_And_5_Days_After_Due_Date()
        {
            mockRepository.Setup(e => e.AddBill(It.IsAny <Bill>()));
            var duePercent = DueDaysPercent.Between3And5Days;

            var service = new BillsToPayService(mockRepository.Object);

            var billReturn = await service.AddBill(new BillDTO
            {
                Name          = "Water",
                OriginalPrice = 100,
                DueDate       = new DateTime(2020, 10, 10),
                PayDate       = new DateTime(2020, 10, 14)
            });

            mockRepository.Verify(e => e.AddBill(It.Is <Bill>(e => e.Name == "Water" &&
                                                              e.Interest == duePercent.Interest &&
                                                              e.Fine == duePercent.Fine)), Times.AtLeastOnce());
        }