Exemplo n.º 1
0
        public void AggregateExtendedDataSummarizeQuantity()
        {
            var list = this.GetExtendedList();

            var provider = new GroupOperationsProvider <ExtendedData>();

            IEnumerable <ExtendedData> result = provider.Execute(
                list,
                new List <string> {
                "Name"
            },
                new List <string> {
                "Price"
            },
                new List <string> {
                "Quantity", "StockQuantity"
            });

            Assert.AreEqual(2, result.Count());

            ExtendedData[] arrayResult = result.ToArray();

            var data1 = arrayResult[0];

            this.AssertDataObject(data1, 0, "GRE", 21, 5);
            Assert.AreEqual(6, data1.StockQuantity);

            var data2 = arrayResult[1];

            this.AssertDataObject(data2, 0, "RT", 85, 33);
            Assert.AreEqual(90, data2.StockQuantity);
        }
Exemplo n.º 2
0
        public void AggregateByTwoGroups()
        {
            List <Data> list = this.GetList();

            var provider = new GroupOperationsProvider <Data>();

            IEnumerable <Data> result = provider.Execute(list, new List <string> {
                "Name", "Price"
            });

            Assert.AreEqual(8, result.Count());

            // Aggregated
            // new Data { Id = 3, Name = "AA", Quantity = 43, Price = 6 },
            // new Data { Id = 3, Name = "AA", Quantity = 2, Price = 6 },
        }
Exemplo n.º 3
0
        public void InvalidFieldNameInQuantityList()
        {
            List <Data> item = this.GetList(3);

            var provider = new GroupOperationsProvider <Data>();

            IEnumerable <Data> result = provider.Execute(item, new List <string> {
                "Name"
            }, new List <string> {
                "Fake"
            });

            List <Data> listedResult = result.ToList();

            Data data1 = listedResult[0];

            Assert.AreEqual(1, listedResult.Count);

            this.AssertDataObject(data1, 0, "AAA", 0, 0);
        }
Exemplo n.º 4
0
        public void EmptyAverageList()
        {
            List <Data> list = this.GetList();

            var provider = new GroupOperationsProvider <Data>();
            var result   = provider.Execute(
                list,
                new List <string> {
                "Name"
            },
                null,
                new List <string> {
                "Quantity"
            });

            var listedResult = result.ToList();

            var data1 = listedResult[0];

            this.AssertDataObject(data1, 0, "AAA", 21, 0);
        }
Exemplo n.º 5
0
        public void ReceiveFourGroupsOneSumOneAverage()
        {
            var list = this.GetList();

            GroupOperationsProvider <Data> provider = new GroupOperationsProvider <Data>();

            IEnumerable <Data> result = provider.Execute(
                list,
                new List <string> {
                "Name"
            },
                new List <string> {
                "Price"
            },
                new List <string> {
                "Quantity"
            });

            Assert.NotNull(result);
            Assert.AreEqual(4, result.Count());

            List <Data> listedResult = result.ToList();

            var data1 = listedResult[0];

            this.AssertDataObject(data1, 0, "AAA", 21, 5);

            var Data = listedResult[1];

            this.AssertDataObject(Data, 0, "AA", 51, 33);

            var data3 = listedResult[2];

            this.AssertDataObject(data3, 0, "ADA", 24, 6);

            var data4 = listedResult[3];

            this.AssertDataObject(data4, 0, "AEA", 42, 345);
        }