public void Connect_Returns_False_And_Does_Not_Create_Connection_When_Input_Port_Is_Initial_PortAndFinalPort_Is_Null() { //Arrange var plumber = new DataPlumber(); var mockDestPort = new Mock<IInputDataPort>(); var mockSrcPort = new Mock<IOutputDataPort>(); plumber.SetInitialPort(mockDestPort.Object); //Act bool result = plumber.Connect(); //Assert IDataPipe dPipe = plumber.DataPipe; IPipe pipe = plumber.Pipe; Assert.False(result); Assert.Null(dPipe); Assert.Null(pipe); }
public void Connect_Fires_ConnectionCreatingEvent_Before_Creating_The_Connection() { //Arrange var plumber = new DataPlumber(); var helper = new HelperForPlumbers(); plumber.ConnectionCreating += new PlumbingEventHandler(helper.ConnectionCreating_DummyHandler); var mockDestPort = new Mock<IInputDataPort>(); var mockSrcPort = new Mock<IOutputDataPort>(); var mockPipe = new Mock<IDataPipe>(); plumber.SetInitialPort(mockDestPort.Object); plumber.SetFinalPort(mockSrcPort.Object); (plumber as DataPlumber).DataPipe = mockPipe.Object; //Act plumber.Connect(); //Assert Assert.Equal(1, helper.ConnectionCreating_TimesCalled); }
public void Pipe_Returns_IPipeObject_Resulting_From_Connect() { //Arrange var plumber = new DataPlumber(); var mockDestPort = new Mock<IInputDataPort>(); var mockSrcPort = new Mock<IOutputDataPort>(); var mockPipe = new Mock<IDataPipe>(); plumber.SetInitialPort(mockSrcPort.Object); plumber.SetFinalPort(mockDestPort.Object); (plumber as DataPlumber).DataPipe = mockPipe.Object; //Act bool result = plumber.Connect(); //Assert IPipe pipe = plumber.Pipe; Assert.NotNull(pipe); }
public void Connect_Returns_True_And_Creates_Connection_When_Output_Port_Is_Initial_Port_Then_Input_Port_Is_Final_Port() { //Arrange var plumber = new DataPlumber(); var mockDestPort = new Mock<IInputDataPort>(); var mockSrcPort = new Mock<IOutputDataPort>(); var mockPipe = new Mock<IDataPipe>(); plumber.SetInitialPort(mockSrcPort.Object); plumber.SetFinalPort(mockDestPort.Object); (plumber as DataPlumber).DataPipe = mockPipe.Object; //Act bool result = plumber.Connect(); //Assert Assert.True(result); }