示例#1
0
        public void Add_Int_Var_Then_Remove_By_Id_And_Verify_Count()
        {
            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);

            Assert.Equal(1, mgr.Count);
            mgr.Remove(var.Id);

            Assert.Equal(0, mgr.Count);
        }
示例#2
0
        public void Add_Int_Var_By_Values_Then_Retrieve_And_Verify()
        {
            var mgr = new VarMgr();
            Variable<int> var = mgr.Add<int>(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            Variable<int> resultVar = null;

            resultVar = mgr.GetVariable<int>(Constants.VAR_INT_NAME);

            Assert.NotNull(resultVar);
            Assert.Same(var, resultVar);
            Assert.Equal(Constants.VAR_INT_VAL, resultVar.Value);
        }
示例#3
0
        public void Add_Int_Var_By_Values_Then_Retrieve_By_Name_Indexer()
        {
            var mgr = new VarMgr();
            Variable<int> var = mgr.Add<int>(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            IVariable resultIVar = null;

            resultIVar = mgr[Constants.VAR_INT_NAME];

            Assert.NotNull(resultIVar);
            Assert.Same(var, resultIVar);
            Assert.IsType<int>(resultIVar.ValueItem);
            Assert.Equal(Constants.VAR_INT_VAL, resultIVar.ValueItem);
        }
示例#4
0
        public void Verify_Is_Name_In_Use_When_A_Name_Is_Not_In_Use()
        {
            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);

            bool result = mgr.IsNameInUse(Constants.VAR_FLOAT_NAME);

            Assert.False(result);
        }
示例#5
0
        public void Variables_Cleared_Event_Fired_When_Clear_Called()
        {
            var mgr = new VarMgr();
            var helper = new HelperForIVarMgr();
            mgr.VariablesCleared+=new VariablesClearedEventHandler(helper.VariablesCleared_DummyHandler);

            mgr.Add<int>(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            mgr.Add<double>(Constants.VAR_DOUBLE_NAME, Constants.VAR_DOUBLE_VAL);
            mgr.Add<string>(Constants.VAR_STR_NAME, Constants.VAR_STR_VAL);

            mgr.Clear();

            Assert.Equal(1, helper.VariablesCleared_TimesCalled);
        }
示例#6
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);
        }
示例#7
0
        public void VariableChangedEvent_Is_Fired_After_Variable_Is_Added_By_Values()
        {
            var mgr = new VarMgr();
            var helper = new HelperForIVarMgr();
            mgr.VariableChanged += new VariableChangeEventHandler(helper.VariableChanged_DummyHandler);

            Variable<int> var = mgr.Add(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);

            Assert.Equal(1, helper.VariableChanged_TimesCalled);
            Assert.NotNull(var);
        }
示例#8
0
        public void Identif_VarDependents_Event_Is_Fired_After_Identify_Var_Dependents_By_Name_Called()
        {
            var mgr = new VarMgr();
            var helper = new HelperForIVarMgr();
            mgr.IdentifyVarDependents += new IdentifyVarDependentsEventHandler(helper.IdentifyVarDependents_DummyHandler);
            Variable<double> var = new Variable<double>(Constants.VAR_DOUBLE_ID, Constants.VAR_DOUBLE_NAME, Constants.VAR_DOUBLE_VAL);
            mgr.Add<double>(var);

            mgr.IdentifyDependents(var.Name);
            Assert.Equal(1, helper.IdentifyVarDependents_TimesCalled);
        }
示例#9
0
        public void Get_Variable_Returns_Typed_Variable()
        {
            var mgr = new VarMgr();
            Variable<int> var = mgr.Add<int>(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            Variable<int> resultVar = null;

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

            Assert.NotNull(resultVar);
            Assert.Same(var, resultVar);
        }
示例#10
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
        }
示例#11
0
        public void ClearD_eletes_All_Vars()
        {
            var mgr = new VarMgr();
            mgr.Add<int>(Constants.VAR_INT_NAME, Constants.VAR_INT_VAL);
            mgr.Add<double>(Constants.VAR_DOUBLE_NAME, Constants.VAR_DOUBLE_VAL);
            mgr.Add<string>(Constants.VAR_STR_NAME, Constants.VAR_STR_VAL);

            Assert.Equal(3, mgr.Count);
            mgr.Clear();
            Assert.Equal(0, mgr.Count);
        }
示例#12
0
        public void Add_One_Var_And_Verify_Count()
        {
            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);

            Assert.Equal(1, mgr.Count);
        }