Exemplo n.º 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");
        }
Exemplo n.º 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"]);

        }
Exemplo n.º 3
0
        public void CopyCommandShouldCopyValue()
        {
            IContext ctx = new ContextBase();
            Zetetic.Chain.Generic.CopyCommand cmd = new Zetetic.Chain.Generic.CopyCommand();
            ctx["in"] = "value";
            cmd.FromKey = "in";
            cmd.ToKey = "out";
            cmd.Execute(ctx);

            Assert.IsNotNull(ctx["out"], "'out' value must be present in modified context");
            Assert.AreEqual("value", ctx["out"]);
            
        }
Exemplo n.º 4
0
        public void CatalogShouldRefuseMissingRequiredProperties()
        {
            IContext ctx = new ContextBase();
            Zetetic.Chain.Generic.CopyCommand cmd = new Zetetic.Chain.Generic.CopyCommand();
            ctx["in"] = "value";
            cmd.FromKey = null;
            cmd.ToKey = "out";
            cmd.Name = "test";

            ICatalog cat = new XmlCatalog();
            cat[cmd.Name] = cmd;

            Assert.Fail("Should have had exception");

        }
Exemplo n.º 5
0
        public void AddCommandWithMissingPropertyShouldThrowAppExceptionTest()
        {
            _catalog["foo"] = new Zetetic.Chain.Generic.CopyCommand() { Name = "foo" };

            Assert.Fail("Should not reach here without exception");
        }