示例#1
0
        public void AverageTimeSpanTest()
        {
            var sum = new SubtotalSummaryFunc("average", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetCalculateDelegate = type => (e.Compile());
            sum.DataSource           = new DataSource(new object[] { new Test(TimeSpan.FromHours(1)), new Test(TimeSpan.FromHours(2)), new Test(TimeSpan.FromHours(3)) });

            sum.Calculate(sum.DataSource).Should().Be(TimeSpan.FromHours(2));
        }
示例#2
0
        public void SumIntTest()
        {
            var sum = new SubtotalSummaryFunc("sum", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetCalculateDelegate = type => e.Compile();
            sum.DataSource           = new DataSource(new object[] { new Test(1), new Test(2), new Test(3) });

            sum.Calculate(sum.DataSource).Should().Be(6);
        }
示例#3
0
        public void AverageDoubleTest()
        {
            var sum = new SubtotalSummaryFunc("average", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetCalculateDelegate = type => (e.Compile());
            sum.DataSource           = new DataSource(new object[] { new Test(1.5), new Test(2d), new Test(3.5), new Test(4.5) });

            sum.Calculate(sum.DataSource).Should().Be(2.875);
        }
示例#4
0
        public void StDevDoubleTest()
        {
            var sum = new SubtotalSummaryFunc("stdev", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetCalculateDelegate = type => (e.Compile());
            sum.DataSource           = new DataSource(new object[] { new Test(10d), new Test(20d), new Test(30d), new Test(40d), new Test(50d), new Test(60d), new Test(70d) });

            ((double)sum.Calculate(sum.DataSource)).Should().BeInRange(21.6, 21.61);
        }
示例#5
0
        public void MinDateTimeTest()
        {
            var sum = new SubtotalSummaryFunc("min", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetCalculateDelegate = type => (e.Compile());
            sum.DataSource           = new DataSource(new object[] { new Test(new DateTime(2017, 01, 01)), new Test(new DateTime(2016, 01, 01)), new Test(new DateTime(2018, 01, 01)) });

            sum.Calculate(sum.DataSource).Should().Be(new DateTime(2016, 01, 01));
        }
        public void AverageIntTest()
        {
            var sum = new SubtotalSummaryFunc("average", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetExpression = type => (e);
            sum.DataSource    = new DataSource(new object[] { new Test(1), new Test(2), new Test(3) });

            sum.Calculate(sum.DataSource).Should().Be(2);
        }
        public void SumTimeSpanTest()
        {
            var sum = new SubtotalSummaryFunc("sum", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetExpression = type => (e);
            sum.DataSource    = new DataSource(new object[] { new Test(TimeSpan.FromHours(1)), new Test(TimeSpan.FromHours(2)), new Test(TimeSpan.FromHours(3)) });

            sum.Calculate(sum.DataSource).Should().Be(TimeSpan.FromHours(6));
        }
        public void SumDoubleTest()
        {
            var sum = new SubtotalSummaryFunc("sum", 1);
            Expression <Func <Test, object> > e = o => o.val;

            sum.GetExpression = type => (e);
            sum.DataSource    = new DataSource(new object[] { new Test(1.5), new Test(2d), new Test(3.5) });

            sum.Calculate(sum.DataSource).Should().Be(7d);
        }