Exemplo n.º 1
0
        public void SummarizeQuantity()
        {
            var orders = new List <Order>
            {
                new Order()
                {
                    Quantity = 1
                },
                new Order()
                {
                    Quantity = 2
                },
                new Order()
                {
                    Quantity = 3
                },
                new Order()
                {
                    Quantity = 4
                },
                new Order()
                {
                    Quantity = 5
                },
            };
            var excepted = new List <int> {
                3, 7, 5
            };

            Assert.AreEqual(excepted, MySummarize.SummarizeByGroup(orders, 2, o => o.Quantity));
        }
Exemplo n.º 2
0
        public void SizeWrong()
        {
            var orders = new List <Order>
            {
                new Order()
                {
                    Quantity = 1
                },
                new Order()
                {
                    Quantity = 2
                },
                new Order()
                {
                    Quantity = 3
                },
                new Order()
                {
                    Quantity = 4
                },
                new Order()
                {
                    Quantity = 5
                },
            };

            Action act = () => MySummarize.SummarizeByGroup(orders, -1, o => o.Quantity);

            act.Should().Throw <ArgumentException>().WithMessage("size should >0");
        }
Exemplo n.º 3
0
        public void SummarizePrice()
        {
            var excepted = new List <int> {
                700, 1220, 1390
            };

            Assert.AreEqual(excepted, MySummarize.SummarizeByGroup(products, 4, p => p.Price));
        }
Exemplo n.º 4
0
        public void SummarizeCost()
        {
            var excepted = new List <int> {
                63, 162, 261, 109
            };

            Assert.AreEqual(excepted, MySummarize.SummarizeByGroup(products, 3, p => p.Cost));
        }