예제 #1
0
        public void SellPolicy_shouldReturnPolicy()
        {
            var now    = DateTime.Now;
            var date   = new DateTime(now.Year + 1, now.Month, now.Day, now.Hour, now.Minute, now.Second);
            var policy = _company.SellPolicy("car", date, 3, GetRisks());

            policy.Should().NotBe(null);
            policy.NameOfInsuredObject.Should().Be("car");
            policy.ValidTill.Should().Be(date.AddMonths(3));
        }
예제 #2
0
        public void PremiumCalculator_ShouldCalculatePremiumForSoldPolicyWithOnlyInitialRisks()
        {
            List <Risk> riskList = new List <Risk>();

            riskList.Add(Risk1);
            riskList.Add(Risk2);

            var effectiveDate = DateTime.Now;

            var soldPolicy = Company.SellPolicy(DEFAULT_OBJECT_NAME, effectiveDate, 6, riskList);

            var policyID = IdGenerator.ConstructPolicyId(DEFAULT_OBJECT_NAME, effectiveDate);

            var premium = PremiumCalculator.CalculatePremiumOfSoldPolicy(DEFAULT_OBJECT_NAME, effectiveDate);

            Assert.AreEqual(651.48m, premium);
        }
        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);
        }
예제 #4
0
        public void CanSellAValidPolicyOneYear()
        {
            var risks = GetMockRisks();

            InsuranceCompany.AvailableRisks = risks;

            var policy = InsuranceCompany.SellPolicy("obj1", new DateTime(2018, 11, 5), 2, GetMockRisks());

            Assert.That(policy.InsuredRisks, Is.EqualTo(risks));
            Assert.That(policy.NameOfInsuredObject, Is.EqualTo("obj1"));
            Assert.That(policy.Premium, Is.EqualTo(6));
            Assert.That(policy.ValidFrom, Is.EqualTo(new DateTime(2018, 11, 5)));
            Assert.That(policy.ValidTill, Is.EqualTo(new DateTime(2019, 1, 5)));
        }
        public void SellPolicy_NameOfInsuredObjectNull_ThrowsException()
        {
            Action result = () => _target.SellPolicy(null, DateTime.Now.AddDays(-2), 0, new List <Risk>());

            Assert.ThrowsException <ArgumentNullException>(result);
        }
예제 #6
0
 public void SellPolicy_ShouldThrowIfNameIsNull()
 {
     Assert.That(() => Company.SellPolicy(null, It.IsAny <DateTime>(), It.IsAny <short>(),
                                          It.IsAny <IList <Risk> >()), Throws.Exception);
 }
예제 #7
0
 public void InsuranceCompany_ShouldBeAbleToSellPolicyWithInitialListOfRisks()
 {
     Company.SellPolicy(DEFAULT_OBJECT_NAME, DateTime.Now, 6, new List <Risk>());
     Assert.AreEqual(1, FakeStorage.Instance.PolicyList.Count);
 }