예제 #1
0
        private void RunAssertion <T>(
            EventRepresentationChoice eventRepresentationEnum,
            string additionalAnnotations,
            string typename,
            FunctionSendEvent send,
            Func <object, object> optionalValueConversion,
            IEnumerable <Pair <T, ValueWithExistsFlag> > tests,
            Type expectedPropertyType)
        {
            var stmtText = eventRepresentationEnum.GetAnnotationText() + additionalAnnotations + " select " +
                           "item.id? as myid, " +
                           "exists(item.id?) as exists_myid " +
                           "from " + typename;
            var stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            var listener = new SupportUpdateListener();

            stmt.AddListener(listener);

            Assert.AreEqual(expectedPropertyType, stmt.EventType.GetPropertyType("myid"));
            Assert.AreEqual(typeof(bool?), TypeHelper.GetBoxedType(stmt.EventType.GetPropertyType("exists_myid")));
            Assert.IsTrue(eventRepresentationEnum.MatchesClass(stmt.EventType.UnderlyingType));

            foreach (var pair in tests)
            {
                send.Invoke(_epService, pair.First);
                var @event = listener.AssertOneGetNewAndReset();
                SupportEventInfra.AssertValueMayConvert(@event, "myid", (ValueWithExistsFlag)pair.Second, optionalValueConversion);
            }

            stmt.Dispose();
        }
        private void RunAssertion(
            RegressionEnvironment env,
            string typename,
            FunctionSendEvent send,
            Func <object, object> optionalValueConversion,
            Pair <object, object>[] tests,
            Type expectedPropertyType,
            RegressionPath path)
        {
            var stmtText = "@Name('s0') select Id? as myid, exists(Id?) as exists_myid from " + typename;

            env.CompileDeploy(stmtText, path).AddListener("s0");

            Assert.AreEqual(expectedPropertyType, env.Statement("s0").EventType.GetPropertyType("myid"));
            Assert.AreEqual(typeof(bool?), env.Statement("s0").EventType.GetPropertyType("exists_myid"));

            foreach (var pair in tests)
            {
                send.Invoke(env, pair.First, typename);
                var @event = env.Listener("s0").AssertOneGetNewAndReset();
                SupportEventInfra.AssertValueMayConvert(@event, "myid", (ValueWithExistsFlag)pair.Second, optionalValueConversion);
            }

            env.UndeployAll();
        }
        private void RunAssertion <T>(
            string typename,
            FunctionSendEvent send,
            Func <object, object> optionalValueConversion,
            IEnumerable <Pair <T, ValueWithExistsFlag> > tests,
            Type expectedPropertyType)
        {
            var stmtText = "select id? as myid, exists(id?) as exists_myid from " + typename;
            var stmt     = _epService.EPAdministrator.CreateEPL(stmtText);
            var listener = new SupportUpdateListener();

            stmt.AddListener(listener);

            Assert.AreEqual(expectedPropertyType, stmt.EventType.GetPropertyType("myid"));
            Assert.AreEqual(typeof(bool?), stmt.EventType.GetPropertyType("exists_myid"));

            foreach (var pair in tests)
            {
                send.Invoke(_epService, pair.First);
                var @event = listener.AssertOneGetNewAndReset();
                SupportEventInfra.AssertValueMayConvert(@event, "myid", (ValueWithExistsFlag)pair.Second, optionalValueConversion);
            }

            stmt.Dispose();
        }