Пример #1
0
        public void ThrowIfInsuredObjectNameIsNullOrEmpty(string nameOfInsuredObject)
        {
            var policy          = new Policy();
            var insurancePeriod = new NewInsurancePeriod(DateTime.Now, fixture.Create <short>());
            var insuredRisks    = fixture.CreateMany <Risk>().ToList();

            var policyAggregate = new PolicyAggregate(policy);

            Assert.Throws <MissingNameOfInsuredObjectException>(() =>
                                                                policyAggregate.Create(nameOfInsuredObject, insurancePeriod, insuredRisks));
        }
Пример #2
0
        public void ThrowIfRisksAreNotSelected()
        {
            var policy = new Policy();
            var nameOfInsuredObject = fixture.Create <string>();
            var insurancePeriod     = new NewInsurancePeriod(DateTime.Now, fixture.Create <short>());
            var insuredRisks        = new List <Risk>();

            var policyAggregate = new PolicyAggregate(policy);

            Assert.Throws <MissingInitialInsuredRisksException>(() =>
                                                                policyAggregate.Create(nameOfInsuredObject, insurancePeriod, insuredRisks));
        }
Пример #3
0
        public void CalculatePremiumOnCreation()
        {
            var policy = new Policy();
            var nameOfInsuredObject = fixture.Create <string>();
            var insurancePeriod     = new NewInsurancePeriod(DateTime.Now, fixture.Create <short>());
            var insuredRisks        = fixture.CreateMany <Risk>().ToList();

            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.Create(nameOfInsuredObject, insurancePeriod, insuredRisks);

            Assert.True(policy.Premium > 0m);
        }
Пример #4
0
        public void PropagateArgumentsToEntityOnCreation()
        {
            var policy = new Policy();
            var nameOfInsuredObject = fixture.Create <string>();
            var insurancePeriod     = new NewInsurancePeriod(DateTime.Now, fixture.Create <short>());
            var insuredRisks        = fixture.CreateMany <Risk>().ToList();

            var policyAggregate = new PolicyAggregate(policy);

            policyAggregate.Create(nameOfInsuredObject, insurancePeriod, insuredRisks);

            Assert.Equal(nameOfInsuredObject, policy.NameOfInsuredObject);
            Assert.Equal(insurancePeriod.From, policy.ValidFrom);
            Assert.Equal(insurancePeriod.Till, policy.ValidTill);
            Assert.Equal(insuredRisks, policy.InsuredRisks);
        }