상속: System.MarshalByRefObject, ICatalog
예제 #1
0
        public void LookupCommandTest()
        {
            IContext ctx = new ContextBase();
            ctx["test"] = "value";

            Zetetic.Chain.Generic.CopyCommand toLookup = new Zetetic.Chain.Generic.CopyCommand();
            toLookup.FromKey = "test";
            toLookup.ToKey = "x";
            toLookup.Name = "findMe";

            Zetetic.Chain.Generic.LookupCommand cmd = new Zetetic.Chain.Generic.LookupCommand();
            cmd.Command = "findMe";
            cmd.Name = "finder";
            cmd.CatalogKey = "CATALOG";

            ICatalog cat = new CatalogBase();
            cat[toLookup.Name] = toLookup;
            cat[cmd.Name] = cmd;
            ctx[cmd.CatalogKey] = cat;

            cat["finder"].Execute(ctx);

            Assert.AreEqual(ctx["x"], "value");
        }
예제 #2
0
        public void GeneralChainingTest()
        {
            IContext ctx = new ContextBase();
            ctx["in"] = "value";

            Zetetic.Chain.IChain chain = ChainFactory.GetFactory().CreateChain();
            chain.Name = "chain";

            Zetetic.Chain.Generic.CopyCommand cmd = new Zetetic.Chain.Generic.CopyCommand();            
            cmd.FromKey = "in";
            cmd.ToKey = "middle";

            chain.Add(cmd);

            cmd = new Zetetic.Chain.Generic.CopyCommand();
            cmd.FromKey = "middle";
            cmd.ToKey = "third";

            chain.Add(cmd);

            Zetetic.Chain.Generic.RemoveCommand remo = new Zetetic.Chain.Generic.RemoveCommand();
            remo.FromKey = "middle";

            chain.Add(remo);

            ICatalog cat = new CatalogBase();
            cat[chain.Name] = chain;

            cat["chain"].Execute(ctx);

            Assert.AreEqual("value", ctx["third"]);
            Assert.IsNull(ctx["middle"]);

        }