コード例 #1
0
        public void AdditiveMethod_CalculatesFactorsCorrectly()
        {
            FactorBasedMethod additiveMethod = TestObjectBuilder.CreateAdditiveMethod();

            IEnumerable <decimal> factors = new List <decimal>()
            {
                0.243m, 0.222m, 0.154m, 0.142m, 0.09m, 0.037m
            };

            bool calculatedCorrectly = additiveMethod.Factors
                                       .Zip(factors, (x, y) => Math.Abs(x - Math.Round(y, 3)) <= 0.001m)
                                       .Aggregate(true, (x, y) => x && y);

            Assert.IsTrue(calculatedCorrectly);
        }
コード例 #2
0
        public void ChainLadder_CalculatesFactorsCorrectly()
        {
            IEnumerable <decimal> factors = new List <decimal>()
            {
                1.899454m, 1.3288m, 1.232147m, 1.119969m, 1.044378m
            };

            FactorBasedMethod chainLadder = TestObjectBuilder.CreateChainLadderMethod();

            bool calculatedCorrectly = chainLadder.Factors
                                       .Zip(factors, (x, y) => Math.Abs(x - Math.Round(y, 6)) <= 1e-6m)
                                       .Aggregate(true, (x, y) => x && y);

            Assert.IsTrue(calculatedCorrectly);
        }