示例#1
0
        public void Set_Variable_Value_Changes_The_Value()
        {
            var mgr = new VarMgr();
            Variable<int> var = new Variable<int>(Constants.VAR_INT_ID, Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            mgr.Add<int>(var);

            Variable<int> resultVar = null;
            int newVal = 7733;

            resultVar = mgr.GetVariable<int>(var.Name);

            Assert.Equal(Constants.VAR_INT_VAL, resultVar.Value);

            mgr.SetVariableValue<int>(var.Name, newVal);
            resultVar = mgr.GetVariable<int>(var.Name);
            Assert.Equal(newVal, resultVar.Value);
        }
示例#2
0
        public void Events_Fired_Before_And_After_Set_Variable_Value_Executed()
        {
            var mgr = new VarMgr();
            var helper = new HelperForIVarMgr();
            mgr.VariableChanging += new VariableChangeEventHandler(helper.VariableChanging_DummyHandler);
            mgr.VariableChanged += new VariableChangeEventHandler(helper.VariableChanged_DummyHandler);
            Variable<double> var = new Variable<double>(Constants.VAR_DOUBLE_ID, Constants.VAR_DOUBLE_NAME, Constants.VAR_DOUBLE_VAL);
            mgr.Add<double>(var);

            double newVal = 777.888;
            mgr.SetVariableValue<double>(var.Id, newVal);

            Assert.Equal(1, helper.VariableChanging_TimesCalled);
            Assert.Equal(2, helper.VariableChanged_TimesCalled);  // Add method calls it too
        }