Example #1
0
        public void UnregisterNestedVariable()
        {
            VariableSet vSet      = new VariableSet();
            VariableSet childVset = new VariableSet();

            Variable inScope = new Variable("Horace", OperandType.String, "I am hungry");

            vSet.RegisterVariable(OperandType.VSet, "child", childVset);
            childVset.RegisterVariable(inScope);

            Assert.IsTrue(vSet.GetVariable("child.Horace") == inScope);

            vSet.UnregisterVariable("child.Horace");

            try
            {
                var variable = vSet.GetVariable("Horace");
                Assert.Fail("Did not throw expected exception");
            }
            catch (KeyNotFoundException knfex)
            {
            }
            catch
            {
                Assert.Fail("Did not throw expected exception");
            }
        }
Example #2
0
        public void UnregisterMissingVariable()
        {
            VariableSet vSet = new VariableSet();

            Variable inScope = new Variable("Horace", OperandType.String, "I am hungry");

            vSet.RegisterVariable(inScope);

            Assert.IsTrue(vSet.GetVariable("Horace") == inScope);

            try
            {
                vSet.UnregisterVariable(inScope);
            }
            catch (KeyNotFoundException knfex)
            {
            }
        }
 private void TestRegister(VariableSet vSet, OperandType type, object initialValue, object expectedValue, bool expectedSucceed)
 {
     try
     {
         var variable = vSet.RegisterVariable(type, "testName", initialValue);
         Assert.AreEqual(true, expectedSucceed);
         Assert.AreEqual(expectedValue, vSet.GetVariable("testName").Value);
         vSet.UnregisterVariable(variable);
     }
     catch (InvalidCastException ice)
     {
         Assert.AreEqual(false, expectedSucceed);
     }
     catch (NullReferenceException nre)
     {
         Assert.AreEqual(false, expectedSucceed);
     }
 }
Example #4
0
        public void UnregisterWrongVariable()
        {
            VariableSet vSet = new VariableSet();

            Variable inScope  = new Variable("Horace", OperandType.String, "I am hungry");
            Variable outScope = new Variable("Horace", OperandType.String, "I am not hungry");

            vSet.RegisterVariable(inScope);

            try
            {
                vSet.UnregisterVariable(outScope);
                Assert.Fail("Expected exception was not thrown");
            }
            catch (ValueNotFoundException vnfex)
            {
            }
            catch
            {
                Assert.Fail("Expected exception was not thrown");
            }
        }