public void InsuranceCompany_ShouldBeAbleToGetPolicy() { List <Risk> riskList = new List <Risk>(); riskList.Add(Risk1); riskList.Add(Risk2); var effectiveDate = DateTime.Now; var validTill = effectiveDate.AddMonths(6); Company.SellPolicy(DEFAULT_OBJECT_NAME, effectiveDate, 6, riskList); var premium = PremiumCalculator.CalculateInitialPremium(riskList, effectiveDate, validTill); var expectedPolicy = new Policy { NameOfInsuredObject = DEFAULT_OBJECT_NAME, ValidFrom = effectiveDate, ValidTill = validTill, InsuredRisks = riskList, Premium = premium }; var policy = Company.GetPolicy(DEFAULT_OBJECT_NAME, effectiveDate); expectedPolicy.Should().BeEquivalentTo(policy); }
public void AddRisk_ShouldAddRiskToPolicy() { var from = new DateTime(2025, 1, 1); var policy = _company.GetPolicy("obj1", from); policy.InsuredRisks.Count.Should().Be(0); _company.AddRisk("obj1", new Risk("Theft", 10M), from); policy.InsuredRisks.Count.Should().Be(1); }
public void GetPolicy_ShouldCallPolicyRepositoryGetOnce() { Company.GetPolicy(It.IsAny <string>(), It.IsAny <DateTime>()); PolicyServiceMock.Verify(mock => mock.GetPolicy(It.IsAny <string>(), It.IsAny <DateTime>()), Times.Once); }
public void RunCompany() { var from = new DateTime(2021, 01, 01, 12, 0, 0); var policy1 = _company.SellPolicy("car", from, 12, _company.AvailableRisks); var policy2 = _company.SellPolicy("car", from.AddMonths(13), 6, _company.AvailableRisks); policy1.Premium.Should().Be(50); policy2.InsuredRisks.Count.Should().Be(2); _company.GetPolicy("car", from).Premium.Should().Be(50); _company.GetPolicy("car", from.AddMonths(13)).Premium.Should().Be(25); _company.AddRisk("car", new Risk("flood", 10), from); _company.AddRisk("car", new Risk("flood", 10), new DateTime(2021, 7, 1, 12, 0, 0)); policy1.InsuredRisks.Count.Should().Be(4); policy1.Premium.Should().Be(65); }
public void CanRetreiveASoldPolicy() { InsuranceCompany.AvailableRisks = GetMockRisks(); var policy1 = InsuranceCompany.SellPolicy("obj1", new DateTime(2018, 11, 5), 2, GetMockRisks()); var policy2 = InsuranceCompany.SellPolicy("obj1", new DateTime(2019, 1, 5), 2, GetMockRisks()); var policy3 = InsuranceCompany.SellPolicy("obj2", new DateTime(2018, 11, 5), 2, GetMockRisks()); var policy4 = InsuranceCompany.GetPolicy("obj1", new DateTime(2018, 12, 6)); Assert.AreSame(policy4, policy1); }
public void GetPolicy_NameOfInsuredObjectNull_ThrowsException() { Action result = () => _target.GetPolicy(null, DateTime.Now.AddDays(-2)); Assert.ThrowsException <ArgumentNullException>(result); }