Ejemplo n.º 1
0
        public void TestGetValue()
        {
            ExprEvaluatorContext exprEvaluatorContext = SupportStatementContextFactory.MakeEvaluatorContext();

            // apply 3 rows to group key 1, all aggregators evaluated their sub-expressions(constants 5 and 2)
            _service.ApplyEnter(new EventBean[1], _groupOneKey, exprEvaluatorContext);
            _service.ApplyEnter(new EventBean[1], _groupOneKey, exprEvaluatorContext);
            _service.ApplyEnter(new EventBean[1], _groupTwoKey, exprEvaluatorContext);

            _service.SetCurrentAccess(_groupOneKey, -1, null);
            Assert.AreEqual(10, _service.GetValue(0, -1, EvaluateParams.EmptyTrue));
            Assert.AreEqual(4, _service.GetValue(1, -1, EvaluateParams.EmptyTrue));
            _service.SetCurrentAccess(_groupTwoKey, -1, null);
            Assert.AreEqual(5, _service.GetValue(0, -1, EvaluateParams.EmptyTrue));
            Assert.AreEqual(2, _service.GetValue(1, -1, EvaluateParams.EmptyTrue));

            _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext);
            _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext);
            _service.ApplyLeave(new EventBean[1], _groupTwoKey, exprEvaluatorContext);
            _service.ApplyLeave(new EventBean[1], _groupOneKey, exprEvaluatorContext);

            _service.SetCurrentAccess(_groupOneKey, -1, null);
            Assert.AreEqual(10 - 5, _service.GetValue(0, -1, EvaluateParams.EmptyTrue));
            Assert.AreEqual(4 - 2, _service.GetValue(1, -1, EvaluateParams.EmptyTrue));
            _service.SetCurrentAccess(_groupTwoKey, -1, null);
            Assert.AreEqual(5 - 15, _service.GetValue(0, -1, EvaluateParams.EmptyTrue));
            Assert.AreEqual(2 - 6, _service.GetValue(1, -1, EvaluateParams.EmptyTrue));
        }