Exemple #1
0
        public async Task GetCumulativeData_ShouldReturn_ExpectedCumulativeValuesCount()
        {
            // Arrange
            var service = new CumulativeService();

            const int originYear = 2000;

            var claim1 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.Comp
            };
            var claim2 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 1, Value = 10, Type = ProductType.Comp
            };

            var claimA = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.NonComp
            };
            var claimB = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 1, Value = 10, Type = ProductType.NonComp
            };

            var incrementalData = new List <Claim> {
                claim1, claim2, claimA, claimB
            };

            var expectedCount = incrementalData.GroupBy(data => data.Type).Select(g => g.Key).Count();

            // Act
            var result = await service.GetCumulativeData(incrementalData);

            // Assert
            Assert.AreEqual(expectedCount, result.CumulativeValues.Count());
        }
Exemple #2
0
        public async Task GetCumulativeData_ShouldReturn_ExpectedValues()
        {
            // Arrange
            var service = new CumulativeService();

            const int originYear = 2000;

            var claim1 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.Comp
            };
            var claim2 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 1, Value = 10, Type = ProductType.Comp
            };
            var claim3 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 2, Value = 15, Type = ProductType.Comp
            };

            // Act
            var result = await service.GetCumulativeData(new List <Claim> {
                claim1, claim2, claim3
            });

            // Assert
            var expectedValues = new List <double>
            {
                claim1.Value.Value,
                claim1.Value.Value + claim2.Value.Value,
                claim1.Value.Value + claim2.Value.Value + claim3.Value.Value
            };

            Assert.AreEqual(expectedValues, result.CumulativeValues.First().Values);
        }
Exemple #3
0
        public async Task GetCumulativeData_ShouldReturn_ExpectedHeader()
        {
            // Arrange
            var service = new CumulativeService();

            const int originYear = 2000;

            var claim1 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.Comp
            };
            var claim2 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 1, Value = 10, Type = ProductType.Comp
            };
            var claim3 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 2, Value = 15, Type = ProductType.Comp
            };

            // Act
            var result = await service.GetCumulativeData(new List <Claim> {
                claim1, claim2, claim3
            });

            // Assert
            Assert.That(result.Header.MinOriginYear, Is.EqualTo(originYear));
            Assert.That(result.Header.DevelopmentYears, Is.EqualTo(claim3.DevelopmentYear - originYear + 1));
        }
Exemple #4
0
        public void GetCumulativeData_ShouldThrowException_IfInputIsInvalid()
        {
            // Arrange
            var service = new CumulativeService();

            // Act
            async Task AsyncAct() => await service.GetCumulativeData(null);

            // Assert
            var ex = Assert.ThrowsAsync <CumulativeException>(AsyncAct);

            Assert.That(ex.Type, Is.EqualTo(CumulativeExceptionType.InvalidInput));
        }
Exemple #5
0
        public async Task GetCumulativeData_ShouldReturn_CumulativeValues_WithDefaultValue_IfMissing()
        {
            // Arrange
            var service = new CumulativeService();

            const int originYear  = 2000;
            const int originYear2 = originYear + 1;

            var claim1 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.Comp
            };
            var claim2 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 1, Value = 10, Type = ProductType.Comp
            };
            var claim3 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 2, Value = 15, Type = ProductType.Comp
            };

            var claimA = new Claim {
                OriginYear = originYear2, DevelopmentYear = originYear2, Value = 5, Type = ProductType.NonComp
            };
            var claimB = new Claim {
                OriginYear = originYear2, DevelopmentYear = originYear2 + 1, Value = 10, Type = ProductType.NonComp
            };

            var incrementComps = new List <Claim> {
                claim1, claim2, claim3
            };
            var incrementNonComps = new List <Claim> {
                claimA, claimB
            };

            // Act
            var result = await service.GetCumulativeData(incrementComps.Concat(incrementNonComps));

            // Assert
            var comps    = result.CumulativeValues.First(c => c.Type == ProductType.Comp);
            var nonComps = result.CumulativeValues.First(c => c.Type == ProductType.NonComp);

            Assert.AreEqual(incrementNonComps.Count, comps.Values.Count(value => value == default));
            Assert.AreEqual(incrementComps.Count, nonComps.Values.Count(value => value == default));
        }
Exemple #6
0
        public async Task GetCumulativeData_ShouldReturn_EqualValues_ForAllCumulativeValues()
        {
            // Arrange
            var service = new CumulativeService();

            const int originYear  = 2000;
            const int originYear2 = originYear + 1;

            // span over 3 development years - missing 2nd year.
            var claim1 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear, Value = 5, Type = ProductType.Comp
            };
            var claim2 = new Claim {
                OriginYear = originYear, DevelopmentYear = originYear + 2, Value = 10, Type = ProductType.Comp
            };

            var claimA = new Claim {
                OriginYear = originYear2, DevelopmentYear = originYear2, Value = 5, Type = ProductType.NonComp
            };
            var claimB = new Claim {
                OriginYear = originYear2, DevelopmentYear = originYear2 + 1, Value = 10, Type = ProductType.NonComp
            };

            var incrementalData = new List <Claim> {
                claim1, claim2, claimA, claimB
            };

            const int expectedCount = 5;

            // Act
            var result = await service.GetCumulativeData(incrementalData);

            // Assert
            var comps    = result.CumulativeValues.First(c => c.Type == ProductType.Comp);
            var nonComps = result.CumulativeValues.First(c => c.Type == ProductType.NonComp);

            Assert.AreEqual(expectedCount, comps.Values.Count());
            Assert.AreEqual(expectedCount, nonComps.Values.Count());
        }