Пример #1
0
        public void ThrowIfRemovedRiskIsNotInsured()
        {
            var validTill = DateTime.Now.AddDays(100);
            var risk      = fixture.Create <Risk>();
            var policy    = fixture.Create <Policy>();

            var policyAggregate = new PolicyAggregate(policy);

            Assert.Throws <InvalidRiskException>(() =>
                                                 policyAggregate.RemoveRisk(risk, validTill));
        }
Пример #2
0
        public void RecalculatePremiumForRemovedRisk()
        {
            var validTill = DateTime.Now;
            var risk      = fixture.Create <Risk>();
            var policy    = fixture.Build <Policy>()
                            .With(p => p.ValidTill, validTill.AddMonths(3))
                            .With(p => p.InsuredRisks, new List <Risk> {
                risk
            })
                            .Create();
            var originalPremium = policy.Premium;

            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.RemoveRisk(risk, validTill);

            Assert.NotEqual(originalPremium, policy.Premium);
        }
Пример #3
0
        public void ThrowIfRemovedRiskEndsSameMonthWithPolicy()
        {
            var validTill = new DateTime(DateTime.Now.Year, 01, 15);
            var risk      = fixture.Create <Risk>();
            var policy    = fixture.Build <Policy>()
                            .With(p => p.ValidTill, new DateTime(DateTime.Now.Year, 01, 30))
                            .With(p => p.InsuredRisks, new List <Risk> {
                risk
            })
                            .Create();

            policy.ValidTill = new DateTime(DateTime.Now.Year, 01, 30);

            var policyAggregate = new PolicyAggregate(policy);

            Assert.Throws <InvalidRiskRemovePeriodException>(() =>
                                                             policyAggregate.RemoveRisk(risk, validTill));
        }