Example #1
0
        public void Connect_Returns_False_And_Does_Not_Create_Connection_When_Input_Port_Is_Initial_PortAndFinalPort_Is_Null()
        {
            //Arrange
            var plumber = new NetworkPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();

            plumber.SetInitialPort(mockDestPort.Object);

            //Act
            bool result = plumber.Connect();

            //Assert
            INetworkPipe dPipe = plumber.NetworkPipe;
            IPipe pipe = plumber.Pipe;

            Assert.False(result);
            Assert.Null(dPipe);
            Assert.Null(pipe);
        }
Example #2
0
        public void Connect_Fires_ConnectionCreatingEvent_Before_Creating_The_Connection()
        {
            //Arrange
            var plumber = new NetworkPlumber();
            var helper = new HelperForPlumbers();
            plumber.ConnectionCreating += new PlumbingEventHandler(helper.ConnectionCreating_DummyHandler);

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

            plumber.SetInitialPort(mockDestPort.Object);
            plumber.SetFinalPort(mockSrcPort.Object);
            (plumber as NetworkPlumber).NetworkPipe = mockPipe.Object;

            //Act
            plumber.Connect();

            //Assert
            Assert.Equal(1, helper.ConnectionCreating_TimesCalled);
        }
Example #3
0
        public void Pipe_Returns_IPipeObject_Resulting_From_Connect()
        {
            //Arrange
            var plumber = new NetworkPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            plumber.SetInitialPort(mockSrcPort.Object);
            plumber.SetFinalPort(mockDestPort.Object);
            (plumber as NetworkPlumber).NetworkPipe = mockPipe.Object;

            //Act
            bool result = plumber.Connect();

            //Assert
            IPipe pipe = plumber.Pipe;

            Assert.NotNull(pipe);
        }
Example #4
0
        public void Connect_Returns_True_And_Creates_Connection_When_Output_Port_Is_Initial_Port_Then_Input_Port_Is_Final_Port()
        {
            //Arrange
            var plumber = new NetworkPlumber();
            var mockDestPort = new Mock<IInputNetworkPort>();
            var mockSrcPort = new Mock<IOutputNetworkPort>();
            var mockPipe = new Mock<INetworkPipe>();

            plumber.SetInitialPort(mockSrcPort.Object);
            plumber.SetFinalPort(mockDestPort.Object);
            (plumber as NetworkPlumber).NetworkPipe = mockPipe.Object;

            //Act
            bool result = plumber.Connect();

            //Assert
            Assert.True(result);
        }