Esempio n. 1
0
        public void SumTest_輸入GroupSize為負數_預期會拋ArgumentException()
        {
            //arrange
            var products = StubProducts();
            var target   = new CalculationByGroupFromCollection();
            var expected = new int[] { 50, 66, 60 };

            int groupSize = -1;
            //act
            Action actual = () => target.Sum <Product>(products, groupSize, (p) => p.Revenue);

            //assert
            actual.ShouldThrow <ArgumentException>();
        }
Esempio n. 2
0
        public void SumTest_由StubProducts中3筆一組_取Cost總和分別為_6_15_24_21()
        {
            //arrange
            var products = StubProducts();
            var target   = new CalculationByGroupFromCollection();

            var expected = new List <int> {
                6, 15, 24, 21
            };
            int groupSize = 3;
            //act
            var actual = target.Sum <Product>(products, groupSize, (p) => p.Cost);

            //assert
            expected.ToExpectedObject().ShouldEqual(actual);
        }
Esempio n. 3
0
        public void SumTest_由StubProducts中4筆一組_取Revenue總和分別為_50_66_60()
        {
            //arrange
            var products = StubProducts();
            var target   = new CalculationByGroupFromCollection();


            var expected = new List <int> {
                50, 66, 60
            };
            int groupSize = 4;
            //act
            var actual = target.Sum <Product>(products, groupSize, (p) => p.Revenue);

            //assert
            expected.ToExpectedObject().ShouldEqual(actual);
        }