Example #1
0
        public void CalculateTest_尋找的欄位若不存在_預期會拋RuntimeBinderException()
        {
            //arrange
            var target = new DynamicCalculator.DynamicCalculator();

            //act
            Action act = () =>
            {
                target.Calculate(_orders, 4, o => o.NotHere).ToList();
            };

            //assert
            act.ShouldThrow <RuntimeBinderException>();
        }
Example #2
0
        public void CalculateTest_3筆成一組_取得Cost的總和_預期為_6_15_24_21()
        {
            //arrange
            var target   = new DynamicCalculator.DynamicCalculator();
            var expected = new List <int> {
                6, 15, 24, 21
            };

            //act
            var result = target.Calculate(_orders, 3, o => o.Cost).ToList();

            //assert
            result.Should().BeEquivalentTo(expected);
        }
Example #3
0
        public void CalculateTest_4筆成一組_取得Revenue的總和_預期為_50_66_60()
        {
            //arrange
            var target   = new DynamicCalculator.DynamicCalculator();
            var expected = new List <int> {
                50, 66, 60
            };

            //act
            var result = target.Calculate(_orders, 4, o => o.Revenue).ToList();

            //assert
            result.Should().BeEquivalentTo(expected);
        }
Example #4
0
        public void CalculateTest_筆數若輸入若小於等於0_則傳回ArgumentException(int divideSize)
        {
            //arrange
            var target = new DynamicCalculator.DynamicCalculator();
            //act
            Action act = () =>
            {
                target.Calculate(_orders, divideSize, o => o.Cost).ToList();;
            };

            //assert
            act
            .ShouldThrow <ArgumentException>()
            .WithMessage("divideSize應為大於0之正整數");
        }