示例#1
0
        public void MinAggregator_Merge()
        {
            var minAggr1 = new MinAggregator("test");
            var minAggr2 = new MinAggregator("test");
            Func <object, string, object> getVal = (r, f) => {
                return(r);
            };

            minAggr1.Push(5, getVal);
            minAggr2.Push(3, getVal);

            minAggr2.Merge(minAggr1);
            Assert.Equal(3, minAggr2.Value);
            minAggr1.Merge(minAggr2);
            Assert.Equal(3, minAggr1.Value);

            // datetime values
            var maxAggr3 = new MinAggregator("test");

            maxAggr3.Push(new DateTime(1983, 5, 6), getVal);
            maxAggr3.Push(new DateTime(2000, 1, 1), getVal);
            Assert.Equal(1983, ((DateTime)maxAggr3.Value).Year);

            var maxAggr4 = new MinAggregator("test");

            maxAggr4.Push(new DateTime(2010, 2, 2), getVal);
            maxAggr3.Merge(maxAggr4);
            Assert.Equal(1983, ((DateTime)maxAggr3.Value).Year);
        }
示例#2
0
        public void MinAggregator()
        {
            var minAggr = new MinAggregator("test");
            Func <object, string, object> getVal = (r, f) => {
                Assert.Equal("test", f);
                return(r);
            };

            minAggr.Push(5, getVal);
            Assert.Equal(5, minAggr.Value);
            minAggr.Push(3, getVal);
            Assert.Equal(3, minAggr.Value);
            minAggr.Push(7, getVal);
            Assert.Equal(3, minAggr.Value);
        }