public static Policy StandardOneYearPolicy(DateTime policyStartDate) { var product = ProductsTestData.StandardCarInsurance(); var events = new List <Event> { new InitialPolicyVersionCreated ( "POL01", product.Code, policyStartDate, policyStartDate.AddDays(365), policyStartDate.AddDays(-1), new PersonData("A", "B", "C"), new CarData("A", "B", 2018), new List <PolicyCoverData> { new PolicyCoverData("OC", policyStartDate, policyStartDate.AddDays(365), Money.Euro(500), Money.Euro(500), TimeSpan.FromDays(365)) } ) }; var policy = new Policy(Guid.NewGuid(), events); policy.MarkChangesAsCommitted(); return(policy); }
public void CanAddTheSameCoverTwice() { var product = ProductsTestData.StandardCarInsurance(); var policy = PolicyTestData.StandardOneYearPolicy(new DateTime(2019, 1, 1)); var doubledCover = product.CoverWithCode("OC"); var ex = Throws <ApplicationException>(() => policy.ExtendCoverage ( new DateTime(2019, 7, 1), new CoverPrice(Guid.NewGuid(), doubledCover, Money.Euro(100), TimeSpan.FromDays(365)) )); Equal("This cover is already present", ex.Message); }
public void CanExtendCoverageWithMiddleDayOfPolicy() { var product = ProductsTestData.StandardCarInsurance(); var policy = PolicyTestData.StandardOneYearPolicy(new DateTime(2019, 1, 1)); var newCover = product.CoverWithCode("AC"); policy.ExtendCoverage ( new DateTime(2019, 7, 1), new CoverPrice(Guid.NewGuid(), newCover, Money.Euro(100), TimeSpan.FromDays(365)) ); var resultingEvents = policy.GetUncommittedChanges(); //assert state policy .Should() .HaveVersions(2); policy.Versions.WithNumber(1).Should() .BeActive() .HaveActivePolicyStatus() .HaveTotalPremiumEqualTo(Money.Euro(500)); policy.Versions.WithNumber(2) .Should() .BeDraft() .HaveActivePolicyStatus() .CoverPeriod(new DateTime(2019, 1, 1), new DateTime(2020, 1, 1)) .HaveTotalPremiumEqualTo(Money.Euro(550.41)); //assert events resultingEvents .Should() .BeSingle() .ContainEvent( new CoverageExtendedPolicyVersionCreated ( 2, 1, ValidityPeriod.Between(new DateTime(2019, 7, 1), new DateTime(2020, 1, 1)), new PolicyCoverData("AC", new DateTime(2019, 7, 1), new DateTime(2020, 1, 1), Money.Euro(50.41), Money.Euro(100), TimeSpan.FromDays(365)) ) ); }
public static Offer StandardOneYearOCOfferValidUntil(DateTime validityEnd) { var product = ProductsTestData.StandardCarInsurance(); return(new Offer ( Guid.NewGuid(), "1", product, PersonsTestData.Kowalski(), PersonsTestData.Kowalski(), CarsTestData.OldFordFocus(), TimeSpan.FromDays(365), Money.Euro(500), validityEnd.AddDays(-30), new Dictionary <Cover, Money>() { { product.CoverWithCode("OC"), Money.Euro(500) } } )); }