Beispiel #1
0
        public void TestExtensionContextEvents()
        {
            AddinManager.Registry.EnableAddin ("SimpleApp.SystemInfoExtension,0.1.0");

            counters [0] = new Counter ();
            counters [1] = new Counter ();
            counters [2] = new Counter ();

            GlobalInfoCondition.Value = "";

            ExtensionContext c1 = AddinManager.CreateExtensionContext ();
            ExtensionContext c2 = AddinManager.CreateExtensionContext ();

            ParameterInfoCondition pinfo1 = new ParameterInfoCondition ();
            ParameterInfoCondition pinfo2 = new ParameterInfoCondition ();

            pinfo1.Value = "";
            pinfo2.Value = "";

            c1.RegisterCondition ("InputParameter", pinfo1);
            c2.RegisterCondition ("InputParameter", pinfo2);

            // Test registering

            c1.GetExtensionNode ("/SimpleApp/ExtraWriters").ExtensionNodeChanged += NodeListener_1;
            c2.AddExtensionNodeHandler ("/SimpleApp/ExtraWriters", NodeListener_2);
            AddinManager.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_g);

            counters[0].Check ("t1.0", 2, 2, 0, 0);
            counters[1].Check ("t1.1", 2, 2, 0, 0);
            counters[2].Check ("t1.2", 2, 2, 0, 0);

            c1.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_1);
            c2.AddExtensionNodeHandler ("/SimpleApp/Writers2", NodeListener_2);

            counters[1].Check ("t2.1", 2, 2, 0, 0);
            counters[2].Check ("t2.2", 2, 2, 0, 0);

            c1.ExtensionChanged += ExtensionListener_1;
            c2.ExtensionChanged += ExtensionListener_2;
            AddinManager.ExtensionChanged += ExtensionListener_g;

            counters[0].Check ("t3.0", 0, 0, 0, 0);
            counters[1].Check ("t3.1", 0, 0, 0, 0);
            counters[2].Check ("t3.2", 0, 0, 0, 0);

            CheckWriters ("t4.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t4.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t4.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t4.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters ("t4.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test change global var

            GlobalInfoCondition.Value = "yes2";

            counters[0].Check ("t5.0", 2, 2, 0, 1);
            counters[1].Check ("t5.1", 2, 2, 0, 1);
            counters[2].Check ("t5.2", 2, 2, 0, 1);

            CheckWriters ("t6.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters ("t6.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters ("t6.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2", "cmd:cw1", "cmd:cw2");
            CheckWriters ("t6.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters ("t6.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test change global var

            GlobalInfoCondition.Value = "no";

            counters[0].Check ("t7.0", 2, 0, 2, 1);
            counters[1].Check ("t7.1", 5, 3, 2, 2);
            counters[2].Check ("t7.2", 5, 3, 2, 2);

            CheckWriters ("t7.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t7.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t7.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t7.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");
            CheckWriters ("t7.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:cn1", "cmd:cn2", "cmd:cn3");

            // Test reset global var

            GlobalInfoCondition.Value = "";

            counters[0].Check ("t8.0", 0, 0, 0, 0);
            counters[1].Check ("t8.1", 3, 0, 3, 1);
            counters[2].Check ("t8.2", 3, 0, 3, 1);

            CheckWriters ("t8.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t8.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t8.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t8.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");
            CheckWriters ("t8.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test local var

            pinfo1.Value = "simple";

            counters[0].Check ("t9.0", 0, 0, 0, 0);
            counters[1].Check ("t9.1", 2, 2, 0, 1);
            counters[2].Check ("t9.2", 0, 0, 0, 0);

            CheckWriters ("t9.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t9.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t9.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t9.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters ("t9.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Test local var

            pinfo2.Value = "simple";

            counters[0].Check ("t10.0", 0, 0, 0, 0);
            counters[1].Check ("t10.1", 0, 0, 0, 0);
            counters[2].Check ("t10.2", 2, 2, 0, 1);

            CheckWriters ("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters ("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");

            // Test unset local var

            pinfo2.Value = "";

            counters[0].Check ("t10.0", 0, 0, 0, 0);
            counters[1].Check ("t10.1", 0, 0, 0, 0);
            counters[2].Check ("t10.2", 2, 0, 2, 1);

            CheckWriters ("t10.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t10.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters ("t10.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2");

            // Combined global/local var change

            GlobalInfoCondition.Value = "yes1";
            pinfo2.Value = "x1";

            counters[0].Check ("t11.0", 0, 0, 0, 0);
            counters[1].Check ("t11.1", 0, 0, 0, 0);
            counters[2].Check ("t11.2", 2, 2, 0, 1);

            CheckWriters ("t11.1", null, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t11.2", c1, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t11.3", c2, "/SimpleApp/Writers2", "cmd:w1", "cmd:w2");
            CheckWriters ("t11.4", c1, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:sim1", "cmd:sim2");
            CheckWriters ("t11.5", c2, "/SimpleApp/ExtraWriters", "cmd:ca1", "cmd:ca2", "cmd:c3 x1 and yes1", "cmd:c4 x1 and yes1");

            GlobalInfoCondition.Value = "";
        }
        public override void Setup()
        {
            base.Setup ();

            pinfo = new ParameterInfoCondition ();
            pinfo.Value = "res";
            GlobalInfoCondition.Value = "res";

            ctx = AddinManager.CreateExtensionContext ();
            ctx.RegisterCondition ("InputParameter", pinfo);
        }