Beispiel #1
0
        public void CannotBuyExpiredOffer()
        {
            var       offer = OfferFactory.NewOfferValidUntil(DateTime.Now.AddDays(-5));
            Exception ex    = Throws <ApplicationException>(() => offer.Buy(PolicyHolderFactory.Abc()));

            Equal($"Offer {offer.Number} has expired", ex.Message);
        }
        internal static Offer AlreadyConvertedOffer()
        {
            var offer = NewOfferValidUntil(DateTime.Now.AddDays(5));

            offer.Buy(PolicyHolderFactory.Abc());
            return(offer);
        }
        public void CannotBuyAlreadyConvertedOffer()
        {
            var offer = OfferFactory.AlreadyConvertedOffer();

            Exception ex = Throws<ApplicationException>(() => offer.Buy(PolicyHolderFactory.Abc()));
            Equal($"Offer {offer.Number} is not in new status and cannot be bought", ex.Message);
        }
Beispiel #4
0
        public void CanTerminateActivePolicyInTheMiddleOfCoverPeriod()
        {
            var offer = OfferFactory.NewOfferValidUntil(DateTime.Now.AddDays(5));

            var policy = offer.Buy(PolicyHolderFactory.Abc());

            var terminationResult = policy.Terminate(DateTime.Now.AddDays(3));

            PolicyAssert
            .AssertThat(policy)
            .HasVersions(2)
            .HasVersion(2)
            .StatusIsTerminated();

            PolicyVersionAssert
            .AssertThat(terminationResult.TerminalVersion)
            .TotalPremiumIs(180M);
        }
Beispiel #5
0
        public void CanBuyNewNonExpiredOffer()
        {
            var offer = OfferFactory.NewOfferValidUntil(DateTime.Now.AddDays(5));

            var policy = offer.Buy(PolicyHolderFactory.Abc());

            OfferAssert
            .AssertThat(offer)
            .StatusIsConverted();

            PolicyAssert
            .AssertThat(policy)
            .StatusIsActive()
            .HasVersions(1)
            .HasVersion(1);

            PolicyVersionAssert
            .AssertThat(policy.Versions.WithNumber(1))
            .TotalPremiumIs(offer.TotalPrice);
        }
        internal static Offer NewOfferValidUntil(DateTime offerValidityEnd)
        {
            using (var timeMachine = new TimeMachine(offerValidityEnd.AddDays(-30)))
            {
                var price = new Price(new Dictionary <string, decimal>()
                {
                    ["C1"] = 100M,
                    ["C2"] = 200M
                });

                var offer = Offer.ForPrice
                            (
                    "P1",
                    DateTime.Now,
                    DateTime.Now.AddDays(5),
                    PolicyHolderFactory.Abc(),
                    price
                            );

                return(offer);
            }
        }