コード例 #1
0
        public void CreateOutputContentTest2()
        {
            var productIncrementalValue1 = CreateProductIncrementalValue("Comp", 1992, 1992, 110.0);
            var productIncrementalValue2 = CreateProductIncrementalValue("COMP", 1992, 1993, 170.0);
            var productIncrementalValue3 = CreateProductIncrementalValue("ComP", 1993, 1993, 200.0);

            var productIncrementalValue4  = CreateProductIncrementalValue("Non - Comp", 1990, 1990, 45.2);
            var productIncrementalValue5  = CreateProductIncrementalValue("NON - Comp", 1990, 1991, 64.8);
            var productIncrementalValue6  = CreateProductIncrementalValue("Non - Comp", 1990, 1993, 37.0);
            var productIncrementalValue7  = CreateProductIncrementalValue("Non - CoMp", 1991, 1991, 50.0);
            var productIncrementalValue8  = CreateProductIncrementalValue("Non - ComP", 1991, 1992, 75.0);
            var productIncrementalValue9  = CreateProductIncrementalValue("NoN - Comp", 1991, 1993, 25.0);
            var productIncrementalValue10 = CreateProductIncrementalValue("Non - COMp", 1992, 1992, 55.0);
            var productIncrementalValue11 = CreateProductIncrementalValue("Non - Comp", 1992, 1993, 85.0);
            var productIncrementalValue12 = CreateProductIncrementalValue("Non - Comp", 1993, 1993, 100.0);

            var productIncrementValues = new List <ProductIncrementalValue>()
            {
                productIncrementalValue1,
                productIncrementalValue2,
                productIncrementalValue3,
                productIncrementalValue4,
                productIncrementalValue5,
                productIncrementalValue6,
                productIncrementalValue7,
                productIncrementalValue8,
                productIncrementalValue9,
                productIncrementalValue10,
                productIncrementalValue11,
                productIncrementalValue12
            };


            var mockedCumulativeDataCalculator = new Mock <ICumulativeDataCalculator>();

            mockedCumulativeDataCalculator.Setup(x => x.Calculate(It.Is <Product>(p => p.ProductName == "comp")))
            .Returns(new List <double>()
            {
                0, 0, 0, 0, 0, 0, 0, 110, 280, 200
            });
            mockedCumulativeDataCalculator.Setup(x => x.Calculate(It.Is <Product>(p => p.ProductName == "non - comp")))
            .Returns(new List <double>()
            {
                45.2, 110, 110, 147, 50, 125, 150, 55, 140, 100
            });

            IList <string> expectedOutputList = new List <string>();

            expectedOutputList.Add("1990,4");
            expectedOutputList.Add("comp,0,0,0,0,0,0,0,110,280,200");
            expectedOutputList.Add("non - comp,45.2,110,110,147,50,125,150,55,140,100");

            var outputFormatter = new OutputFormatter(mockedCumulativeDataCalculator.Object);

            CollectionAssert.AreEqual(expectedOutputList, outputFormatter.CreateOutputContent(productIncrementValues));
        }