Esempio n. 1
0
        public void Execute_MultipleKeySingleAggregation_ExpectedResultSet()
        {
            var rs = new ObjectsResultSetResolver(
                new ObjectsResultSetResolverArgs(
                    new[] { new object[] { "alpha", "foo", 1 }, new object[] { "alpha", "foo", 2 }, new object[] { "beta", "foo", 3 }, new object[] { "alpha", "bar", 4 } })
                ).Execute();

            rs.Columns[0].ColumnName = "ColumnA";
            rs.Columns[1].ColumnName = "ColumnB";
            rs.Columns[2].ColumnName = "valueColumn";

            var args = new SummarizeArgs(
                new List <ColumnAggregationArgs>()
            {
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null)
            },
                new List <IColumnDefinitionLight>()
            {
                Mock.Of <IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnA") && x.Type == ColumnType.Text),
                Mock.Of <IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("ColumnB") && x.Type == ColumnType.Text)
            }
                );

            var summarize = new SummarizeEngine(args);
            var result    = summarize.Execute(rs);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Columns.Count, Is.EqualTo(3));
            Assert.That(result.Rows.Cast <DataRow>().Any(x => x["ColumnA"] as string == "alpha" && x["ColumnB"] as string == "foo"));
            Assert.That(result.Rows.Cast <DataRow>().Any(x => x["ColumnA"] as string == "beta" && x["ColumnB"] as string == "foo"));
            Assert.That(result.Rows.Cast <DataRow>().Any(x => x["ColumnA"] as string == "alpha" && x["ColumnB"] as string == "bar"));
            Assert.That(result.Rows.Count, Is.EqualTo(3));
        }
Esempio n. 2
0
        public void Execute_LargeResultSet_ExpectedPerformance(int count)
        {
            var rs = BuildLarge(count);

            var args = new SummarizeArgs(
                new List <ColumnAggregationArgs>()
            {
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Min, ColumnType.Numeric, null),
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Max, ColumnType.Numeric, null),
            },
                new List <IColumnDefinitionLight>()
            {
                Mock.Of <IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("keyColumn") && x.Type == ColumnType.Text)
            }
                );

            var summarize = new SummarizeEngine(args);

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var result = summarize.Execute(rs);

            stopWatch.Stop();
            Assert.That(stopWatch.Elapsed.TotalSeconds, Is.LessThan(10));
        }
Esempio n. 3
0
        public void Execute_SingleKeySingleAggregation_ExpectedResultSet()
        {
            var rs = Build();

            var args = new SummarizeArgs(
                new List <ColumnAggregationArgs>()
            {
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null)
            },
                new List <IColumnDefinitionLight>()
            {
                Mock.Of <IColumnDefinitionLight>(x => x.Identifier == new ColumnNameIdentifier("keyColumn") && x.Type == ColumnType.Text)
            }
                );

            var summarize = new SummarizeEngine(args);
            var result    = summarize.Execute(rs);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Columns.Count, Is.EqualTo(2));
            Assert.That(result.Rows.Cast <DataRow>().Any(x => x["keyColumn"] as string == "alpha"));
            Assert.That(result.Rows.Cast <DataRow>().Any(x => x["keyColumn"] as string == "beta"));
            Assert.That(result.Rows.Count, Is.EqualTo(2));
            Assert.That(Convert.ToInt32(result.Rows.Cast <DataRow>().Single(x => x["keyColumn"] as string == "alpha")["valueColumn"]) == 7);
            Assert.That(Convert.ToInt32(result.Rows.Cast <DataRow>().Single(x => x["keyColumn"] as string == "beta")["valueColumn"]) == 3);
        }
Esempio n. 4
0
        public void Execute_NoKeySingleAggregations_ExpectedResultSet()
        {
            var rs = Build();

            var args = new SummarizeArgs(
                new List <ColumnAggregationArgs>()
            {
                new ColumnAggregationArgs(new ColumnNameIdentifier("valueColumn"), AggregationFunctionType.Sum, ColumnType.Numeric, null),
            },
                new List <IColumnDefinitionLight>()
                );

            var summarize = new SummarizeEngine(args);
            var result    = summarize.Execute(rs);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Columns.Count, Is.EqualTo(1));
            Assert.That(result.Rows.Count, Is.EqualTo(1));
            Assert.That(Convert.ToInt32(result.Rows[0][0]) == 10);
        }