Exemplo n.º 1
0
        public void Ctor_Default_Creates_Instance()
        {
            //Act
            var port = new InputDataPort();

            //Assert
            Assert.NotNull(port);
        }
Exemplo n.º 2
0
        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;
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        public void SourceElement_Returns_Null_If_No_Pipes()
        {
            //Arrange
            var port = new InputDataPort();

            //Act
            IElement element = (port as InputDataPort).SourceElement;

            //Assert
            Assert.Null(element);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }