public void SetUndefinedValueUsingTwoLocalEnviroments()
        {
            BindingEnvironment environment = new BindingEnvironment();

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

            local2.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, local2.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
        }
        public void SetValueThruLocalEnviroment()
        {
            BindingEnvironment environment = new BindingEnvironment();

            environment.SetValue("one", 0);

            LocalBindingEnvironment local = new LocalBindingEnvironment(environment);

            local.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
        }
        public void DefineAndSetGlobalValueThruLocalEnvironment()
        {
            Machine machine = new Machine();
            BindingEnvironment environment = new BindingEnvironment();
            LocalBindingEnvironment local = new LocalBindingEnvironment(environment);

            local.DefineGlobal("global");

            local.SetValue("global", 100);

            Assert.AreEqual(100, local.GetValue("global"));
            Assert.AreEqual(100, environment.GetValue("global"));
            Assert.AreEqual(100, machine.Environment.GetValue("global"));
        }
        public void DefineAndSetGlobalValueThruLocalEnvironment()
        {
            Machine                 machine     = new Machine();
            BindingEnvironment      environment = new BindingEnvironment();
            LocalBindingEnvironment local       = new LocalBindingEnvironment(environment);

            local.DefineGlobal("global");

            local.SetValue("global", 100);

            Assert.AreEqual(100, local.GetValue("global"));
            Assert.AreEqual(100, environment.GetValue("global"));
            Assert.AreEqual(100, machine.Environment.GetValue("global"));
        }
Example #5
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"));
        }
Example #6
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"));
        }
        public void SetValueThruLocalAndNormalEnviroment()
        {
            BindingEnvironment      parent   = new BindingEnvironment();
            LocalBindingEnvironment toplocal = new LocalBindingEnvironment(parent);

            toplocal.SetLocalValue("one", 0);

            BindingEnvironment environment = new BindingEnvironment(toplocal);

            LocalBindingEnvironment local = new LocalBindingEnvironment(environment);

            local.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
            Assert.AreEqual(1, toplocal.GetValue("one"));
            Assert.IsNull(parent.GetValue("one"));
        }
        public void SetValueThruLocalEnviroment()
        {
            BindingEnvironment environment = new BindingEnvironment();
            environment.SetValue("one", 0);

            LocalBindingEnvironment local = new LocalBindingEnvironment(environment);
            local.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
        }
        public void SetValueThruLocalAndNormalEnviroment()
        {
            BindingEnvironment parent = new BindingEnvironment();
            LocalBindingEnvironment toplocal = new LocalBindingEnvironment(parent);

            toplocal.SetLocalValue("one", 0);

            BindingEnvironment environment = new BindingEnvironment(toplocal);

            LocalBindingEnvironment local = new LocalBindingEnvironment(environment);
            local.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
            Assert.AreEqual(1, toplocal.GetValue("one"));
            Assert.IsNull(parent.GetValue("one"));
        }
Example #10
0
        public void SetUndefinedValueUsingTwoLocalEnviroments()
        {
            BindingEnvironment environment = new BindingEnvironment();

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

            local2.SetValue("one", 1);

            Assert.AreEqual(1, local.GetValue("one"));
            Assert.AreEqual(1, local2.GetValue("one"));
            Assert.AreEqual(1, environment.GetValue("one"));
        }