public void Run(RegressionEnvironment env) { var path = new RegressionPath(); env.CompileDeploy("create window AllTrades#keepall as SupportTradeEventWithSide", path); env.CompileDeploy("insert into AllTrades select * from SupportTradeEventWithSide", path); var epl = "@Name('s0') select us, them, corr.Correlation as crl " + "from AllTrades as us, AllTrades as them," + "method:" + typeof(EPLFromClauseMethodNStream).FullName + ".ComputeCorrelation(us, them) as corr\n" + "where us.Side != them.Side and corr.Correlation > 0"; env.CompileDeploy(epl, path).AddListener("s0"); var one = new SupportTradeEventWithSide("T1", "B"); env.SendEventBean(one); Assert.IsFalse(env.Listener("s0").IsInvoked); var two = new SupportTradeEventWithSide("T2", "S"); env.SendEventBean(two); EPAssertionUtil.AssertPropsPerRowAnyOrder( env.Listener("s0").GetAndResetLastNewData(), new [] { "us","them","crl" }, new[] {new object[] {one, two, 1}, new object[] {two, one, 1}}); env.UndeployAll(); }
public static ComputeCorrelationResult ComputeCorrelation( SupportTradeEventWithSide us, SupportTradeEventWithSide them) { return new ComputeCorrelationResult(us != null && them != null ? 1 : 0); }