Пример #1
0
        public void ShouldFilterRelevantBills()
        {
            var billContext = MockRepository.GenerateMock <IBillContext>();

            var scheduleFilters = MockRepository.GenerateMock <IScheduleFilters>();


            var billModel1 = new BillModel {
                UserId = 101, Id = 1
            };
            var billModel2 = new BillModel {
                UserId = 101, Id = 2
            };
            var billModel3 = new BillModel {
                UserId = 101, Id = 3
            };
            var bills = new InMemoryDbSet <BillModel>
            {
                billModel1,
                billModel2,
                billModel3,
            };
            var scheduleRequest = new ScheduleRequest
            {
                StartDate = DateTime.Now.AddDays(-10),
                EndDate   = DateTime.Now.AddDays(10),
                UserId    = 101
            };

            billContext.Stub(c => c.Bills).Return(bills);
            var filteredBills = new List <BillModel> {
                billModel1, billModel3
            };

            scheduleFilters.Stub(f => f.Filter(Arg <IEnumerable <BillModel> > .Matches(b => bills.ContainsAll(b)), Arg <ScheduleRequest> .Is.Equal(scheduleRequest)))
            .Return(filteredBills);

            var paymentScheduleService = new PaymentScheduleService(billContext, scheduleFilters);


            var summaryOfDues = paymentScheduleService.GetSummaryOfDues(scheduleRequest);

            Assert.That(summaryOfDues.Bills, Is.EqualTo(filteredBills));
        }