Esempio n. 1
0
        public void RecalculatePremiumForNewlyAddedRisk()
        {
            var validFrom = DateTime.Now;
            var risk      = fixture.Create <Risk>();
            var policy    = fixture
                            .Build <Policy>()
                            .With(p => p.ValidTill, validFrom.AddMonths(3))
                            .Create();
            var originalPremium = policy.Premium;

            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.AddRisk(risk, validFrom);

            Assert.NotEqual(originalPremium, policy.Premium);
        }
Esempio n. 2
0
        public void ThrowIfAddedRiskAlreadyInsured()
        {
            var validFrom = DateTime.Now;
            var risk      = fixture.Create <Risk>();
            var policy    = fixture
                            .Build <Policy>()
                            .With(p => p.ValidTill, validFrom.AddMonths(3))
                            .With(p => p.InsuredRisks, new List <Risk> {
                risk
            })
                            .Create();
            var originalPremium = policy.Premium;

            var policyAggregate = new PolicyAggregate(policy);

            Assert.Throws <ExistingRiskException>(() =>
                                                  policyAggregate.AddRisk(risk, validFrom));
        }