context: ///////////////////////////////////////////////////////////////////////////////////////
  // Copyright (C) 2006-2015 Esper Team. All rights reserved.                           /
  // http://esper.codehaus.org                                                          /
  // ---------------------------------------------------------------------------------- /
  // The software in this package is published under the terms of the GPL license       /
  // a copy of which has been included with this distribution in the license.txt file.  /
  ///////////////////////////////////////////////////////////////////////////////////////
  
  using System.Collections.Generic;
  
  using com.espertech.esper.common.client.scopetest;
  using com.espertech.esper.common.@internal.support;
  using com.espertech.esper.regressionlib.framework;
  using com.espertech.esper.regressionlib.support.util;
  
  using NUnit.Framework;
  
  namespace com.espertech.esper.regressionlib.suite.epl.join
  {
      public class EPLOuterJoinVarC3Stream
      {
          public static IList<RegressionExecution> Executions()
          {
              IList<RegressionExecution> execs = new List<RegressionExecution>();
              With0(execs);
              With1(execs);
              With2(execs);
              return execs;
          }
  
          public static IList<RegressionExecution> With2(IList<RegressionExecution> execs = null)
          {
              execs = execs ?? new List<RegressionExecution>();
              execs.Add(new EPLJoinOuterInnerJoinRootS2());
              return execs;
          }
  
          public static IList<RegressionExecution> With1(IList<RegressionExecution> execs = null)
          {
              execs = execs ?? new List<RegressionExecution>();
              execs.Add(new EPLJoinOuterInnerJoinRootS1());
              return execs;
          }
  
          public static IList<RegressionExecution> With0(IList<RegressionExecution> execs = null)
          {
              execs = execs ?? new List<RegressionExecution>();
              execs.Add(new EPLJoinOuterInnerJoinRootS0());
              return execs;
          }
  
          private static void TryAssertion(RegressionEnvironment env)
          {
              // Test s0 ... s1 with 0 rows, s2 with 0 rows
              //
              var s0Events = SupportBean_S0.MakeS0("A", new[] {"A-s0-1"});
              SendEvent(env, s0Events);
              Assert.IsFalse(env.Listener("s0").IsInvoked);
  
              // Test s0 ... s1 with 1 rows, s2 with 0 rows
              //
              var s1Events = SupportBean_S1.MakeS1("B", new[] {"B-s1-1"});
              SendEventsAndReset(env, s1Events);
  
              s0Events = SupportBean_S0.MakeS0("B", new[] {"B-s0-1"});
              SendEvent(env, s0Events);
              Assert.IsFalse(env.Listener("s0").IsInvoked);
  
              // Test s0 ... s1 with 0 rows, s2 with 1 rows
              //
              var s2Events = SupportBean_S2.MakeS2("C", new[] {"C-s2-1"});
              SendEventsAndReset(env, s2Events);
  
              s0Events = SupportBean_S0.MakeS0("C", new[] {"C-s0-1"});
              SendEvent(env, s0Events);
              Assert.IsFalse(env.Listener("s0").IsInvoked);
  
              // Test s0 ... s1 with 1 rows, s2 with 1 rows
              //
              s1Events = SupportBean_S1.MakeS1("D", new[] {"D-s1-1"});
              SendEventsAndReset(env, s1Events);
  
              s2Events = SupportBean_S2.MakeS2("D", new[] {"D-s2-1"});
              SendEventsAndReset(env, s2Events);
  
              s0Events = SupportBean_S0.MakeS0("D", new[] {"D-s0-1"});
              SendEvent(env, s0Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s0 ... s1 with 1 rows, s2 with 2 rows
              //
              s1Events = SupportBean_S1.MakeS1("E", new[] {"E-s1-1"});
              SendEventsAndReset(env, s1Events);
  
              s2Events = SupportBean_S2.MakeS2("E", new[] {"E-s2-1", "E-s2-2"});
              SendEventsAndReset(env, s2Events);
  
              s0Events = SupportBean_S0.MakeS0("E", new[] {"E-s0-1"});
              SendEvent(env, s0Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]},
                      new[] {s0Events[0], s1Events[0], s2Events[1]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s0 ... s1 with 2 rows, s2 with 1 rows
              //
              s1Events = SupportBean_S1.MakeS1("F", new[] {"F-s1-1", "F-s1-2"});
              SendEventsAndReset(env, s1Events);
  
              s2Events = SupportBean_S2.MakeS2("F", new[] {"F-s2-1"});
              SendEventsAndReset(env, s2Events);
  
              s0Events = SupportBean_S0.MakeS0("F", new[] {"F-s0-1"});
              SendEvent(env, s0Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]},
                      new[] {s0Events[0], s1Events[1], s2Events[0]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s0 ... s1 with 2 rows, s2 with 2 rows
              //
              s1Events = SupportBean_S1.MakeS1("G", new[] {"G-s1-1", "G-s1-2"});
              SendEventsAndReset(env, s1Events);
  
              s2Events = SupportBean_S2.MakeS2("G", new[] {"G-s2-1", "G-s2-2"});
              SendEventsAndReset(env, s2Events);
  
              s0Events = SupportBean_S0.MakeS0("G", new[] {"G-s0-1"});
              SendEvent(env, s0Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]},
                      new[] {s0Events[0], s1Events[1], s2Events[0]},
                      new[] {s0Events[0], s1Events[0], s2Events[1]},
                      new[] {s0Events[0], s1Events[1], s2Events[1]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s1 ... s0 with 0 rows, s2 with 0 rows
              //
              s1Events = SupportBean_S1.MakeS1("H", new[] {"H-s1-1"});
              SendEvent(env, s1Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {null, s1Events[0], null}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s1 ... s0 with 1 rows, s2 with 0 rows
              //
              s0Events = SupportBean_S0.MakeS0("I", new[] {"I-s0-1"});
              SendEventsAndReset(env, s0Events);
  
              s1Events = SupportBean_S1.MakeS1("I", new[] {"I-s1-1"});
              SendEvent(env, s1Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {null, s1Events[0], null}
                  },
                  GetAndResetNewEvents(env));
              // s0 is not expected in this case since s0 requires results in s2 which didn't exist
  
              // Test s1 ... s0 with 1 rows, s2 with 1 rows
              //
              s0Events = SupportBean_S0.MakeS0("J", new[] {"J-s0-1"});
              SendEventsAndReset(env, s0Events);
  
              s2Events = SupportBean_S2.MakeS2("J", new[] {"J-s2-1"});
              SendEventsAndReset(env, s2Events);
  
              s1Events = SupportBean_S1.MakeS1("J", new[] {"J-s1-1"});
              SendEvent(env, s1Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s1 ... s0 with 1 rows, s2 with 2 rows
              //
              s0Events = SupportBean_S0.MakeS0("K", new[] {"K-s0-1"});
              SendEventsAndReset(env, s0Events);
  
              s2Events = SupportBean_S2.MakeS2("K", new[] {"K-s2-1", "K-s2-1"});
              SendEventsAndReset(env, s2Events);
  
              s1Events = SupportBean_S1.MakeS1("K", new[] {"K-s1-1"});
              SendEvent(env, s1Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
                      new[] {s0Events[0], s1Events[0], s2Events[0]},
                      new[] {s0Events[0], s1Events[0], s2Events[1]}
                  },
                  GetAndResetNewEvents(env));
  
              // Test s1 ... s0 with 2 rows, s2 with 0 rows
              //
              s0Events = SupportBean_S0.MakeS0("L", new[] {"L-s0-1", "L-s0-2"});
              SendEventsAndReset(env, s0Events);
  
              s1Events = SupportBean_S1.MakeS1("L", new[] {"L-s1-1"});
              SendEvent(env, s1Events);
              EPAssertionUtil.AssertSameAnyOrder(
                  new[] {
  
gt:                     new[] {null, s1Events[0], null}