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)); }
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); }
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); }
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); }
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); }