public void TestAggregateFunction() { AggregationMethodFactory aggFactory = ValidatedNodeToTest.Factory; AggregationMethod agg = aggFactory.Make(SupportExprNodeFactory.MethodResService, -1, 1, 1); Assert.AreEqual(typeof(double?), agg.ValueType); Assert.IsNull(agg.Value); agg.Enter(82); Assert.AreEqual(0D, agg.Value); agg.Enter(78); Assert.AreEqual(2D, agg.Value); agg.Enter(70); double result = agg.Value.AsDouble(); Assert.AreEqual("4.4444", result.ToString().Substring(0, 6)); agg.Enter(58); Assert.AreEqual(8D, agg.Value); agg.Enter(42); Assert.AreEqual(12.8D, agg.Value); agg.Leave(82); Assert.AreEqual(12D, agg.Value); agg.Leave(58); result = agg.Value.AsDouble(); Assert.AreEqual("14.2222", result.ToString().Substring(0, 7)); }
public virtual void Enter(Object value) { // if value not already encountered, enter into aggregate if (_valueSet.Add(value)) { _inner.Enter(value); } }
public virtual void Enter(Object value) { var values = (Object[])value; if (!CheckPass(values)) { return; } // if value not already encountered, enter into aggregate if (_valueSet.Add(values[0])) { _inner.Enter(value); } }