public void Ctor_Default_Creates_Instance() { //Act var port = new InputDataPort(); //Assert Assert.NotNull(port); }
internal IInputDataPort _CreateInputDataPort(Guid id, IElement parent) { if (parent == null) return null; IInputDataPort port = new InputDataPort(id, parent); return port; }
public void VerifyConnectionChangeEventHandlerIsImplementedForDataPipes() { // this just runs through event handlers to insure there are no notImplementedExceptions IInputDataPort port = new InputDataPort(); InputPortMgr mgr = new InputPortMgr(); mgr.Add(port); IDataPipe dPipe = _pipeFactory.CreateDataPipe(); port.InboundPipe = dPipe; }
public void Ctor_Creates_Instance_When_Parent_Element_Param_Is_Null_But_Parent_Element_Remains_Null() { //Act var port = new InputDataPort(null); //Assert Assert.NotNull(port); Assert.Null(port.ParentElement); }
public void Ctor_Creates_Instance_When_Parent_Element_Param_Is_Not_Null() { //Arrange var port = new InputDataPort(); var mockElement = new Mock<IElement>(); //Act port = new InputDataPort(mockElement.Object); //Assert Assert.NotNull(port); Assert.NotNull(port.ParentElement); }
public void InputPortMgrHandlesConnectionChangeEventFiredByIInputDataPortWhenAConnectionChanged() { IInputDataPort port = new InputDataPort(); InputPortMgr mgr = new InputPortMgr(); var helper = new HelperForInputPortMgr(); mgr.ConnectionChanging += helper.ConnectionChanging_DummyHandler; mgr.ConnectionChanged += helper.ConnectionChanged_DummyHandler; mgr.Add(port); IDataPipe dPipe = _pipeFactory.CreateDataPipe(); port.InboundPipe = dPipe; Assert.Equal(1, helper.ConnectionChanging_TimesCalled); Assert.Equal(1, helper.ConnectionChanged_TimesCalled); }
public void Blob_Gets_Data_As_A_IBlob() { //Arrange var port = new InputDataPort(); var mockData = new Mock<IFrame>(); var mockPipe = new Mock<IDataPipe>(); mockPipe.Setup(m => m.DataObj).Returns(mockData.Object); port.InboundPipe = mockPipe.Object; //Act IBlob actualData = port.Blob; //Assert Assert.Same(mockData.Object, actualData); }
public void SetIndex_Assigns_Port_Index_For_InputDataPort() { //Arrange IPort port = new InputDataPort(); ISetIndex setter = port as ISetIndex; int initialIndex = port.Index; int actualIndex = 2; Assert.Equal(-1, initialIndex); //Act setter.SetIndex(actualIndex); //Assert int finalIndex = port.Index; Guid newId = Guid.NewGuid(); Assert.Equal(actualIndex, finalIndex); }
public void ParentElement_Assigns_Parent_Element() { //Arrange var port = new InputDataPort(); var mockElement = new Mock<IElement>(); //Act port.ParentElement = mockElement.Object; //Assert Assert.NotNull(port.ParentElement); Assert.Same(mockElement.Object, port.ParentElement); }
public void InputDataObj_Returns_Null_If_Inbound_Pipe_Is_Not_Set() { //Arrange var port = new InputDataPort(); //Act IFrame actualBlob = port.InputDataObj; //Assert Assert.Null(actualBlob); }
public void SourceElement_Returns_Upstream_Element() { //Arrange var port = new InputDataPort(); var mockEl0 = new Mock<IElement>(); var mockPipe0 = new Mock<IDataPipe>(); port.InboundPipe = mockPipe0.Object; mockPipe0.Setup(m => m.SourceElement).Returns(mockEl0.Object); //Act IElement element = (port as InputDataPort).SourceElement; //Assert Assert.NotNull(element); }
public void _inPipe_ContentStatusChangedEventHandler_Fires_Input_AvailabilityChangedEvent() { //Arrange var port = new InputDataPort(); var helper= new HelperForInputPorts(); var mockPipe = new Mock<IDataPipe>(); port.InputAvailabilityChanged += new InputAvailabilityChangedEventHandler<IInputDataPort, InputAvailabilityChangedEventArgs> (helper.InputAvailabilityChanged_DummyHandler); var ea = new PipeStatusChangeEventArgs(PayLoadStatus.Unavailable, PayLoadStatus.Available); //Act port._inPipe_ContentStatusChanged(mockPipe.Object, ea); //Assert Assert.Equal(1, helper.InputAvailabilityChanged_TimesCalled); Assert.NotNull(helper.RecievedEventArgs); }
public void Setting_InboundPipe_UnSubscribes_From_ContentStatusChangeEvent_Of_Pipe_When_Nullified() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); var mockPipe2 = new Mock<IDataPipe>(); var inPort = new InputDataPort_TestStub(); inPort.InboundPipe = mockPipe.Object; // initialize //Act inPort.InboundPipe = mockPipe2.Object; // replace // rais the event the port subscribed to mockPipe2.Raise(m => m.StatusChanged += null, new PipeStatusChangeEventArgs(PayLoadStatus.Unavailable, PayLoadStatus.Available)); //Assert Assert.Equal(0, inPort._inPipe_ContentStatusChanged_TimesCalled); Assert.Null(inPort.RecievedEventArgs); Assert.Null(inPort.RecievedSender); }
public void SourceElement_Returns_Null_If_No_Pipes() { //Arrange var port = new InputDataPort(); //Act IElement element = (port as InputDataPort).SourceElement; //Assert Assert.Null(element); }
public void Setting_InboundPipe_Subscribes_To_Content_StatusChangeEvent_Of_Pipe_When_Pipe_Is_Replaced() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); var mockPipe2 = new Mock<IDataPipe>(); var inPort = port as InputDataPort; // the event should not be fired. var helper = new HelperForInputPorts(); ; // final check is if this even is fired port.InputAvailabilityChanged += new InputAvailabilityChangedEventHandler<IInputDataPort,InputAvailabilityChangedEventArgs> (helper.InputAvailabilityChanged_DummyHandler); inPort.InboundPipe = mockPipe.Object; // initialize //Act inPort.InboundPipe = mockPipe2.Object; // replace // raise the event the port subscribed to mockPipe2.Raise(m => m.StatusChanged += null, new PipeStatusChangeEventArgs(PayLoadStatus.Unavailable, PayLoadStatus.Available)); //Assert Assert.Equal(1, helper.InputAvailabilityChanged_TimesCalled); Assert.NotNull(helper.RecievedEventArgs); Assert.Same(inPort, helper.RecievedSender); }
public void Setting_InboundPipe_Does_Not_Fire_ConnectionChangingEvent_When_Null_Value_Does_Not_Change() { //Arrange var port = new InputDataPort(); var helper= new HelperForInputPorts(); port.ConnectionChanging += new ConnectionChangingEventHandler<IInputDataPort, ConnectionChangingEventArgs> (helper.InputConnecting_DummyHandler); //Act port.InboundPipe = null; //Assert Assert.Equal(0, helper.InputConnecting_TimesCalled); var resultArgs = helper.RecievedEventArgs as ConnectionChangingEventArgs; Assert.Null(resultArgs); }
public void InboundPipe_Gets_And_Sets_The_DataPipe() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); //Act port.InboundPipe = mockPipe.Object; IDataPipe actual = port.InboundPipe; //Assert Assert.Same(mockPipe.Object, actual); }
public void Setting_InboundPipe_Fires_The_ConnectionChangedEvent_With_Action_Set_2_Delete_After_Value_Changes() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); var helper= new HelperForInputPorts(); port.ConnectionChanged += new ConnectionChangedEventHandler<IInputDataPort, ConnectionChangedEventArgs> (helper.InputConnected_DummyHandler); port.InboundPipe = mockPipe.Object; // set pipe, then delete it //Act port.InboundPipe = null; // effectively deletes the connection //Assert Assert.Equal(2, helper.InputConnected_TimesCalled); // firse 2x, for each setting var resultArgs = helper.RecievedEventArgs as ConnectionChangedEventArgs; Assert.NotNull(resultArgs); Assert.Equal(ConnectionAction.Delete, resultArgs.Action); }
public void Setting_InboundPipe_Fires_The_ConnectionChangedEvent_With_Action_Set_2_Add_After_Value_Changes() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); var helper= new HelperForInputPorts(); port.ConnectionChanged += new ConnectionChangedEventHandler<IInputDataPort, ConnectionChangedEventArgs> (helper.InputConnected_DummyHandler); //Act port.InboundPipe = mockPipe.Object; //Assert Assert.Equal(1, helper.InputConnected_TimesCalled); var resultArgs = helper.RecievedEventArgs as ConnectionChangedEventArgs; Assert.NotNull(resultArgs); Assert.Equal(ConnectionAction.Add, resultArgs.Action); }
public void InputDataObj_Gets_And_Sets_DataBlob() { //Arrange var port = new InputDataPort(); var mockData = new Mock<IFrame>(); var mockPipe = new Mock<IDataPipe>(); mockPipe.Setup(m => m.DataObj).Returns(mockData.Object); port.InboundPipe = mockPipe.Object; //Act IFrame actualData = port.InputDataObj; //Assert Assert.NotNull(actualData); Assert.Same(mockData.Object, actualData); }
public void Setting_InboundPipe_Fires_The_ConnectionChangingEvent_With_Action_Set_2_Replace_Before_Value_Changes() { //Arrange var port = new InputDataPort(); var mockPipe = new Mock<IDataPipe>(); var mockPipe2 = new Mock<IDataPipe>(); var helper= new HelperForInputPorts(); ; port.ConnectionChanging += new ConnectionChangingEventHandler<IInputDataPort, ConnectionChangingEventArgs> (helper.InputConnecting_DummyHandler); port.InboundPipe = mockPipe.Object; // set pipe, then delete it //Act port.InboundPipe = mockPipe2.Object; // replace //Assert Assert.Equal(2, helper.InputConnecting_TimesCalled); var resultArgs = helper.RecievedEventArgs as ConnectionChangingEventArgs; Assert.NotNull(resultArgs); Assert.Equal(ConnectionAction.Replace, resultArgs.Action); }