예제 #1
0
        public void CannotConvertStartPolicyAfterOfferExpiryDate()
        {
            var offer = OffersTestData.StandardOneYearOCOfferValidUntil(new DateTime(2019, 1, 10));

            var ex = Throws <ApplicationException>(() => Policy.ConvertOffer(offer, "POL0001", new DateTime(2019, 1, 10),
                                                                             new DateTime(2019, 1, 15)));

            Equal("Offer not valid at policy start date", ex.Message);
        }
예제 #2
0
        public void CannotConvertOfferToPolicyAfterItsRejected()
        {
            var offer = OffersTestData.RejectedOfferValidUntil(new DateTime(2019, 1, 10));

            var ex = Throws <ApplicationException>(() => Policy.ConvertOffer(offer, "POL0001", new DateTime(2019, 1, 10),
                                                                             new DateTime(2019, 1, 10)));

            Equal("Offer already rejected", ex.Message);
        }
예제 #3
0
        public void CannotConvertOfferToPolicyAfterItExpires()
        {
            var offer = OffersTestData.StandardOneYearOCOfferValidUntil(new DateTime(2019, 1, 10));

            var ex = Throws <ApplicationException>(() => Policy.ConvertOffer(offer, "POL0001", new DateTime(2019, 1, 12),
                                                                             new DateTime(2019, 1, 15)));

            Equal("Offer expired", ex.Message);
        }
예제 #4
0
        public CreatePolicyResult CreatePolicy(CreatePolicyRequest request)
        {
            var offer  = dataStore.Offers.WithNumber(request.OfferNumber);
            var policy = Policy.ConvertOffer(offer, Guid.NewGuid().ToString(), request.PurchaseDate, request.PolicyStartDate);

            dataStore.Policies.Add(policy);
            dataStore.CommitChanges();
            return(new CreatePolicyResult
            {
                PolicyNumber = policy.Number
            });
        }
예제 #5
0
        public void CanConvertOfferToPolicyBeforeItExpires()
        {
            var offer = OffersTestData.StandardOneYearOCOfferValidUntil(new DateTime(2019, 1, 31));

            var policy = Policy.ConvertOffer(offer, "POL0001", new DateTime(2019, 1, 12), new DateTime(2019, 1, 15));

            NotNull(policy);
            Single(policy.Versions);
            Equal(PolicyStatus.Active, policy.Versions.WithNumber(1).PolicyStatus);
            Equal(PolicyVersionStatus.Active, policy.Versions.WithNumber(1).VersionStatus);
            Equal(Money.Euro(500), policy.Versions.WithNumber(1).TotalPremium);
        }
        public async Task <CreatePolicyResult> Handle(CreatePolicyCommand command, CancellationToken cancellationToken)
        {
            var offer = await dataStore.Offers.WithNumber(command.OfferNumber);

            var policy = Policy.ConvertOffer(offer, Guid.NewGuid().ToString(), command.PurchaseDate,
                                             command.PolicyStartDate);

            dataStore.Policies.Add(policy);
            await dataStore.CommitChanges();

            await mediator.Publish(new PolicyCreated(policy));

            return(new CreatePolicyResult
            {
                PolicyNumber = policy.Number
            });
        }
        public static Policy StandardOneYearPolicy(DateTime policyStartDate)
        {
            var offer = OffersTestData.StandardOneYearOCOfferValidUntil(policyStartDate.AddDays(10));

            return(Policy.ConvertOffer(offer, "POL0001", policyStartDate.AddDays(-1), policyStartDate));
        }