public void SumByPagingTest_column_cost_paging_2_should_1_1_1_2_1()
        {
            IProductSource source     = Substitute.For <IProductSource>();
            ColumnType     columnType = ColumnType.Cost;
            int            paging     = 2;

            source.GetSource().ReturnsForAnyArgs(_products);

            List <int> expected = new List <int> {
                1, 1, 1, 2, 1
            };

            PagingHelper helper = new PagingHelper(source);
            List <int>   actual = helper.SumByPaging(columnType, paging);

            CollectionAssert.AreEquivalent(expected, actual);
        }
        public void SumByPagingTest_column_sell_price_paging_3_should_3_6_9()
        {
            IProductSource source     = Substitute.For <IProductSource>();
            ColumnType     columnType = ColumnType.SellPrice;
            int            paging     = 3;

            source.GetSource().ReturnsForAnyArgs(_products);

            List <int> expected = new List <int> {
                3, 6, 9
            };

            PagingHelper helper = new PagingHelper(source);
            List <int>   actual = helper.SumByPaging(columnType, paging);

            CollectionAssert.AreEquivalent(expected, actual);
        }
示例#3
0
        public List <int> SumByPaging(ColumnType type, int pagingCount)
        {
            List <Product> products = _source.GetSource();

            List <PagingProductSum> productSums = Paging(products, pagingCount);

            switch (type)
            {
            case ColumnType.Cost:
                return(productSums.Select(s => s.Cost).ToList());

            case ColumnType.Revenue:
                return(productSums.Select(s => s.Revenue).ToList());

            case ColumnType.SellPrice:
                return(productSums.Select(s => s.SellPrice).ToList());

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }