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)); }
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)); }
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); }
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); }