public void CannotTerminatePolicyAfterCoverEnds() { var policy = PolicyTestData.StandardOneYearPolicy(new DateTime(2019, 1, 1)); var terminationDate = new DateTime(2020, 1, 2); var ex = Assert.Throws <ApplicationException>(() => policy.TerminatePolicy(terminationDate)); Equal("No active version at given date", ex.Message); }
public void CanTerminatePolicyInTheMiddle() { var policy = PolicyTestData.StandardOneYearPolicy(new DateTime(2019, 1, 1)); var terminationDate = new DateTime(2019, 7, 1); policy.TerminatePolicy(terminationDate); Equal(2, policy.Versions.Count()); Equal(Money.Euro(500), policy.Versions.WithNumber(1).TotalPremium); Equal(PolicyVersionStatus.Active, policy.Versions.WithNumber(1).VersionStatus); Equal(PolicyStatus.Terminated, policy.Versions.WithNumber(2).PolicyStatus); Equal(PolicyVersionStatus.Draft, policy.Versions.WithNumber(2).VersionStatus); Equal(terminationDate, policy.Versions.WithNumber(2).VersionValidityPeriod.ValidFrom); Equal(terminationDate.AddDays(-1), policy.Versions.WithNumber(2).CoverPeriod.ValidTo); Equal(new DateTime(2019, 1, 1), policy.Versions.WithNumber(2).CoverPeriod.ValidFrom); Equal(Money.Euro(246.58), policy.Versions.WithNumber(2).TotalPremium); }
public void CanUndoTermination() { var policyStartedAt = new DateTime(2019, 1, 1); var policyTerminatedAt = new DateTime(2019, 7, 1); var policy = PolicyTestData.StandardOneYearPolicyTerminated(policyStartedAt, policyTerminatedAt); policy.CancelLastAnnex(); Equal(2, policy.Versions.Count()); Equal(Money.Euro(500), policy.Versions.WithNumber(1).TotalPremium); Equal(PolicyVersionStatus.Active, policy.Versions.WithNumber(1).VersionStatus); Equal(PolicyStatus.Active, policy.Versions.WithNumber(1).PolicyStatus); Equal(PolicyStatus.Terminated, policy.Versions.WithNumber(2).PolicyStatus); Equal(PolicyVersionStatus.Cancelled, policy.Versions.WithNumber(2).VersionStatus); Equal(policyTerminatedAt, policy.Versions.WithNumber(2).VersionValidityPeriod.ValidFrom); Equal(policyTerminatedAt.AddDays(-1), policy.Versions.WithNumber(2).CoverPeriod.ValidTo); Equal(new DateTime(2019, 1, 1), policy.Versions.WithNumber(2).CoverPeriod.ValidFrom); Equal(Money.Euro(246.58), policy.Versions.WithNumber(2).TotalPremium); }
public void CanExtendCoverageWithMiddleDayOfPolicy() { var product = ProductsTestData.StandardCarInsurance(); var policy = PolicyTestData.StandardOneYearPolicy(new DateTime(2019, 1, 1)); var newCover = product.Covers.WithCode("AC"); policy.ExtendCoverage ( new DateTime(2019, 7, 1), new CoverPrice(Guid.NewGuid(), newCover, Money.Euro(100), TimeSpan.FromDays(365)) ); Equal(2, policy.Versions.Count()); Equal(Money.Euro(500), policy.Versions.WithNumber(1).TotalPremium); Equal(PolicyVersionStatus.Active, policy.Versions.WithNumber(1).VersionStatus); Equal(Money.Euro(550.41), policy.Versions.WithNumber(2).TotalPremium); Equal(PolicyVersionStatus.Draft, policy.Versions.WithNumber(2).VersionStatus); Equal(PolicyVersionStatus.Draft, policy.Versions.WithNumber(2).VersionStatus); }