public void RequestVariableValuesForParamValidation_DoesNotFireRequestVariableValuesEventIfNoVarNamesInListToSend()
        {
            var element = new NetworkPropertiesElement();
            var mockParamMgr = new Moq.Mock<INetworkPropertiesElementParamMgr>();
            var helper = new HelperForElements();
            string[] varNames = { };
            var ea = new RequestVariableValuesEventArgs(varNames);

            element.RequestVariableValues += new RequestVariableValuesEventHandler<IElement>(helper.RequestVariableValues_DummyHandler);

            mockParamMgr.Setup(m => m.VarNamesDependedUpon).Returns(varNames);

            element.ParamMgr = mockParamMgr.Object;
            element.UpdateVariableValuesForParamValidation();
            Assert.Equal(0, helper.RequestVariableValues_TimesCalled);
        }
예제 #2
0
        public void RequestVariableValuesForParamValidationMethodFiresRequestVariableValuesEvent()
        {
            IdentNodeCoresElement myEl = _element as IdentNodeCoresElement;
            ISetParamMgr paramMgrSetter = _element as ISetParamMgr;
            var mockParamMgr = new Mock<IIdentNodeCoresParamMgr>();
            HelperForElements helper = new HelperForElements();
            string[] varNames = { "Var A", "Var B" };
            RequestVariableValuesEventArgs ea = new RequestVariableValuesEventArgs(varNames);

            _element.RequestVariableValues += new RequestVariableValuesEventHandler<IElement>(helper.RequestVariableValues_DummyHandler);
            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.DefaultBehavior.Strict = StrictFlags.ArbitraryMethodsAllowed;
                recorder.ExpectAndReturn(mockParamMgr.VarNamesDependedUpon, varNames);
                helper.RequestVariableValues_DummyHandler(null, null);
            }

            paramMgrSetter.SetMgr(mockParamMgr);
            myEl.UpdateVariableValuesForParamValidation();
            MockManager.Verify();
        }
예제 #3
0
파일: WorkSpace.cs 프로젝트: BgRva/Blob1
        internal void element_RequestVariableValues(IElement sender, RequestVariableValuesEventArgs ea)
        {
            if (sender != null)
                if (ea.VariableNames != null && ea.VariableNames.Length > 0)
                {
                    IVariable[] vars = new IVariable[ea.VariableNames.Length];
                    for (int i = 0; i < ea.VariableNames.Length; i++)
                    {
                        vars[i] = _varMgr[ea.VariableNames[i]];
                    }

                    sender.UpdateVariableDependencyValues(vars);
                }
        }
예제 #4
0
 /// <summary>
 /// Triggers the RequestVariableValues event.
 /// </summary>
 protected virtual void OnRequestVariableValues(RequestVariableValuesEventArgs ea)
 {
     if (RequestVariableValues != null)
         RequestVariableValues(this, ea);
 }
예제 #5
0
 /// <summary>
 /// Retrieves the variable names that this element is dependant upon, and fires the
 /// <see cref="RequestVariableValues"/> with the list, if there is 1 or more var names
 /// in the list.
 /// </summary>
 internal void UpdateVariableValuesForParamValidation()
 {
     string[] varNames = _paramMgr.VarNamesDependedUpon;
     if (varNames != null && varNames.Length > 0)
     {
         RequestVariableValuesEventArgs ea = new RequestVariableValuesEventArgs(varNames);
         OnRequestVariableValues(ea);
     }
 }
예제 #6
0
        public void element_RequestVariableValuesEventHandlerCallsUpdateVariableDependencyValues()
        {
            var wkSpce = new WorkSpace();
            var mockVarMgr = new Mock<IVarMgr>();
            var mockVarA = new Mock<IVariable>();
            var element = new ElementCallDummy();

            string[] varNames = { "Var A"};
            var ea = new RequestVariableValuesEventArgs(varNames);
            mockVarMgr.Setup(m => m["Var A"]).Returns(mockVarA.Object);

            wkSpce.VarMgr = mockVarMgr.Object;
            wkSpce.element_RequestVariableValues(element, ea);
            Assert.Equal(1, element.UpdateVariableDependencyValues_TimesCalled);
        }
예제 #7
0
        public void element_RequestVariableValuesEventHandlerDoesNothingIfSender_Is_Null()
        {
            var wkSpce = new WorkSpace();
            var mockVarMgr = new Mock<IVarMgr>();
            var mockVarA = new Mock<IVariable>();

            string[] varNames = { "Var A" };
            var ea = new RequestVariableValuesEventArgs(varNames);
            mockVarMgr.Setup(m => m["Var A"]).Returns(mockVarA.Object);

            wkSpce.VarMgr = mockVarMgr.Object;
            wkSpce.element_RequestVariableValues(null, ea);
            mockVarMgr.Verify(m => m["Var A"], Times.Never());
        }
예제 #8
0
 internal void _Element_RequestVariableValues(IElement sender, RequestVariableValuesEventArgs ea)
 {
     throw new NotImplementedException("The method or operation is not implemented.");
 }
예제 #9
0
 public void RequestVariableValues_DummyHandler(IElement sender, RequestVariableValuesEventArgs ea)
 {
     RequestVariableValues_TimesCalled++;
 }