Ejemplo n.º 1
0
        public void ExecuteVarCommand()
        {
            VarCommand command = new VarCommand("foo", new ConstantExpression(10));

            IBindingEnvironment environment = new BindingEnvironment();
            IBindingEnvironment local = new LocalBindingEnvironment(environment);
            IBindingEnvironment local2 = new LocalBindingEnvironment(local);

            command.Execute(local2);

            Assert.IsTrue(local2.ContainsName("foo"));
            Assert.IsFalse(local.ContainsName("foo"));
            Assert.IsFalse(environment.ContainsName("foo"));

            Assert.AreEqual(10, local2.GetValue("foo"));
        }
Ejemplo n.º 2
0
        public void ExecuteVarCommandWithNullExpression()
        {
            VarCommand command = new VarCommand("foo", null);

            IBindingEnvironment environment = new BindingEnvironment();
            IBindingEnvironment local = new LocalBindingEnvironment(environment);
            IBindingEnvironment local2 = new LocalBindingEnvironment(local);

            command.Execute(local2);

            Assert.IsTrue(local2.ContainsName("foo"));
            Assert.IsFalse(local.ContainsName("foo"));
            Assert.IsFalse(environment.ContainsName("foo"));

            Assert.IsNull(local2.GetValue("foo"));
        }
Ejemplo n.º 3
0
        public void ExecuteGlobalCommand()
        {
            GlobalCommand command = new GlobalCommand("global");
            Machine machine = new Machine();

            IBindingEnvironment environment = new BindingEnvironment();

            command.Execute(environment);

            environment.SetValue("global", 100);

            Assert.IsFalse(environment.ContainsName("global"));
            Assert.IsTrue(machine.Environment.ContainsName("global"));
            Assert.AreEqual(100, machine.Environment.GetValue("global"));
        }