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); }
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(); }
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); } }
/// <summary> /// Triggers the RequestVariableValues event. /// </summary> protected virtual void OnRequestVariableValues(RequestVariableValuesEventArgs ea) { if (RequestVariableValues != null) RequestVariableValues(this, ea); }
/// <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); } }
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); }
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()); }
internal void _Element_RequestVariableValues(IElement sender, RequestVariableValuesEventArgs ea) { throw new NotImplementedException("The method or operation is not implemented."); }
public void RequestVariableValues_DummyHandler(IElement sender, RequestVariableValuesEventArgs ea) { RequestVariableValues_TimesCalled++; }