Beispiel #1
0
        public void SumAggregator()
        {
            var sumAggr = new SumAggregator("test");
            Func <object, string, object> getVal = (r, f) => {
                Assert.Equal("test", f);
                return(r);
            };

            sumAggr.Push(5, getVal);
            Assert.Equal(5M, sumAggr.Value);
            sumAggr.Push(3, getVal);
            Assert.Equal(8M, sumAggr.Value);
        }
Beispiel #2
0
        public void SumAggregator_Merge()
        {
            var sumAggr1 = new SumAggregator("test");
            var sumAggr2 = new SumAggregator("test");
            Func <object, string, object> getVal = (r, f) => {
                return(r);
            };

            for (int i = 0; i < 10; i++)
            {
                sumAggr1.Push(i, getVal);
                sumAggr2.Push(i % 2, getVal);
            }

            sumAggr1.Merge(sumAggr2);
            Assert.Equal(50M, Convert.ToDecimal(sumAggr1.Value));
            Assert.Equal(20, (int)sumAggr1.Count);
        }