示例#1
0
        public void Ctor_Default_Creates_Instance()
        {
            //Arrange, Act
            var unPlumber = new NetworkUnPlumber();

            //Assert
            Assert.NotNull(unPlumber);
        }
示例#2
0
        public IUnPlumber CreateUnPlumber(IPipe pipe)
        {
            IUnPlumber plumber = null;

            if (pipe != null)
            {
                if (pipe is IDataPipe)
                {
                    plumber = new DataUnPlumber();
                }
                else if (pipe is INetworkPipe)
                {
                    plumber = new NetworkUnPlumber();
                }
            }

            return plumber;
        }
示例#3
0
        public void Disconnect_Removes_The_Connection_And_Returns_True()
        {
            //Arrange
            var unPlumber = new NetworkUnPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            mockPipe.Setup(m => m.SourceNetworkPort).Returns(mockSrcPort.Object);          // for setting dataPipe property
            mockPipe.Setup(m => m.DestinationNetworkPort).Returns(mockDestPort.Object);    // for setting dataPipe property

            unPlumber.NetworkPipe = mockPipe.Object;

            //Act
            bool result = unPlumber.Disconnect();

            //Assert
            Assert.True(result);
        }
示例#4
0
        public void DisConnect_Fires_ConnectionCreatingEvent_Before_Creating_The_Connection()
        {
            //Arrange
            var unPlumber = new NetworkUnPlumber();
            var helper = new HelperForPlumbers();
            unPlumber.ConnectionDeleting += new ConnectionDeletionEventHandler(helper.ConnectionDeleting_DummyHandler);

            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            mockPipe.Setup(m => m.SourceNetworkPort).Returns(mockSrcPort.Object);          // for setting dataPipe property
            mockPipe.Setup(m => m.DestinationNetworkPort).Returns(mockDestPort.Object);    // for setting dataPipe property

            unPlumber.NetworkPipe = mockPipe.Object;

            //Act
            bool result = unPlumber.Disconnect();

            //Assert
            Assert.True(result);
        }
示例#5
0
        public void NetworkPipe_SetsAndGetsPipe()
        {
            //Arrange
            var unPlumber = new NetworkUnPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            //Act
            unPlumber.NetworkPipe = mockPipe.Object;

            //Assert
            IPipe actualPipe = unPlumber.Pipe;

            Assert.NotNull(actualPipe);
            Assert.Same(mockPipe.Object, actualPipe);
        }
示例#6
0
        public void Reset_Resets_For_A_New_DisConnect()
        {
            //Arrange
            var unPlumber = new NetworkUnPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            mockPipe.Setup(m => m.SourceNetworkPort).Returns(mockSrcPort.Object);
            mockPipe.Setup(m => m.DestinationNetworkPort).Returns(mockDestPort.Object);

            unPlumber.NetworkPipe = mockPipe.Object;

            //Act
            unPlumber.Reset();

            //Assert
            IInputPort actualDestPort = unPlumber.DestinationPort;
            IOutputPort actualSrcPort = unPlumber.SourcePort;
            IInputNetworkPort actualDestNetworkPort = unPlumber.DestinationNetworkPort;
            IOutputNetworkPort actualSrcNetworkPort = unPlumber.SourceNetworkPort;
            IPipe actualPipe = unPlumber.Pipe;
            INetworkPipe actualNetworkPipe = unPlumber.NetworkPipe;

            Assert.Null(actualNetworkPipe);
            Assert.Null(actualPipe);
            Assert.Null(actualDestNetworkPort);
            Assert.Null(actualSrcNetworkPort);
            Assert.Null(actualDestPort);
            Assert.Null(actualSrcPort);
        }
示例#7
0
        public void NetworkPipe_Sets_Pipe_And_Source_Port_And_Dest_Port()
        {
            //Arrange
            var unPlumber = new NetworkUnPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            mockPipe.Setup(m => m.SourceNetworkPort).Returns(mockSrcPort.Object);
            mockPipe.Setup(m => m.DestinationNetworkPort).Returns(mockDestPort.Object);

            //Act
            unPlumber.NetworkPipe = mockPipe.Object;

            //Assert
            IInputPort actualDestPort = unPlumber.DestinationPort;
            IOutputPort actualSrcPort = unPlumber.SourcePort;

            Assert.NotNull(actualDestPort);
            Assert.NotNull(actualSrcPort);
            Assert.Same(mockDestPort.Object, actualDestPort);
            Assert.Same(mockSrcPort.Object, actualSrcPort);
        }