public void Can_calculate_number_of_remaining_cycle() { var rp = new RecurringPayment { Id = 6, CycleLength = 2, CyclePeriod = RecurringProductCyclePeriod.Days, TotalCycles = 3, StartDateUtc = new DateTime(2010, 3, 1), CreatedOnUtc = new DateTime(2010, 1, 1), IsActive = true, }; _orderService.InsertRecurringPayment(rp); _orderProcessingService.GetCyclesRemaining(rp).Should().Be(3); //add one history record _orderService.InsertRecurringPaymentHistory(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); _orderProcessingService.GetCyclesRemaining(rp).Should().Be(2); //add one more history record _orderService.InsertRecurringPaymentHistory(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); _orderProcessingService.GetCyclesRemaining(rp).Should().Be(1); //add one more history record _orderService.InsertRecurringPaymentHistory(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); _orderProcessingService.GetCyclesRemaining(rp).Should().Be(0); //add one more history record _orderService.InsertRecurringPaymentHistory(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); _orderProcessingService.GetCyclesRemaining(rp).Should().Be(0); }