public void Ctor_Default_Creates_Instance() { //Arrange, Act var unPlumber = new NetworkUnPlumber(); //Assert Assert.NotNull(unPlumber); }
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; }
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); }
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); }
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); }
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); }
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); }