public async Task CanCalculateNextPaymentDateWithDaysAsCyclePeriod() { var rp = new RecurringPayment { CycleLength = 7, CyclePeriod = RecurringProductCyclePeriod.Days, TotalCycles = 3, StartDateUtc = new DateTime(2010, 3, 1), CreatedOnUtc = new DateTime(2010, 1, 1), IsActive = true, InitialOrderId = 1 }; await _orderService.InsertRecurringPaymentAsync(rp); var nextPaymentDate = await _orderProcessingService.GetNextPaymentDateAsync(rp); nextPaymentDate.Should().Be(new DateTime(2010, 3, 1)); //add one history record await _orderService.InsertRecurringPaymentHistoryAsync(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); nextPaymentDate = await _orderProcessingService.GetNextPaymentDateAsync(rp); nextPaymentDate.Should().Be(new DateTime(2010, 3, 8)); //add one more history record await _orderService.InsertRecurringPaymentHistoryAsync(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); nextPaymentDate = await _orderProcessingService.GetNextPaymentDateAsync(rp); nextPaymentDate.Should().Be(new DateTime(2010, 3, 15)); //add one more history record await _orderService.InsertRecurringPaymentHistoryAsync(new RecurringPaymentHistory { RecurringPaymentId = rp.Id }); nextPaymentDate = await _orderProcessingService.GetNextPaymentDateAsync(rp); nextPaymentDate.Should().BeNull(); }