public NetworkPropertiesFxPresenter CreatePresenter(INetworkPropertiesElementFx fx, INetworkPropertiesView view)
 {
     NetworkPropertiesFxPresenter pres = null;
     if (fx != null && view != null)
     {
         pres = new NetworkPropertiesFxPresenter(fx, view);
     }
     return pres;
 }
        public void CTor()
        {
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();

            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);
            Assert.NotNull(_presenter);
            Assert.NotNull(_presenter.NetworkPropertiesFx);
            Assert.NotNull(_presenter.NetworkPropertiesView);
            Assert.Same(mockFx.Object, _presenter.NetworkPropertiesFx);
            Assert.Same(mockView.Object, _presenter.NetworkPropertiesView);
        }
        public void CastOff()
        {
            var joiner = new NetworkPropertiesElementJoiner();

            var mockView =new Mock<INetworkPropertiesView>();
            var mockFx =new Mock<INetworkPropertiesElementFx>();
            var presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            Assert.NotNull(presenter.NetworkPropertiesFx);
            joiner.CastOff(presenter);

            Assert.Null(presenter.NetworkPropertiesFx);
        }
        public void Fx_Getter_Returns_Fx_As_An_ICompoundFx()
        {
            var mockFx = new Mock<INetworkPropertiesElementFx>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);

            Assert.Null(_presenter.NetworkPropertiesFx);
            _presenter.NetworkPropertiesFx = mockFx.Object;

            ICompoundFx actualFx = _presenter.Fx;

            Assert.NotNull(actualFx);
            Assert.Same(mockFx.Object, actualFx);
        }
        public void Initialize_Performs_View_Initializations()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            string properties = "Blah";

            mockFx.Setup(m => m.Properties).Returns(properties);
            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            //Act
            _presenter.Initialize();

            //Assert
            mockView.Verify(m => m.SetPropertiesText(properties), Times.Once);
        }
        public void _View_FxViewClosing_EventHandler_Calls_Fx_Cancel()
        {
            var mockView = new Mock<INetworkPropertiesView>();
            var mock2ndView = mockView.As<ISecondaryFxView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var mockCmpdFx = mockFx.As<ICompoundFx>();
            var ea = new ViewActionEventArgs();

            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            //Act
            _presenter._View_FxViewClosing(mockView.Object, ea);

            //Assert
            mockCmpdFx.Verify(m => m.Cancel(), Times.Once);
        }
        public void _View_FxViewClosing_Does_Not_Call_Fx_Cancel_If_Sender_Is_Null()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var mockCmpdFx = mockFx.As<ICompoundFx>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;

            //Act
            _presenter._View_FxViewClosing(null, new ViewActionEventArgs());

            //Assert
            mockCmpdFx.Verify(m => m.Cancel(), Times.Never);
        }
        public void _Fx_StatusChanged_EventHandler_Calls_View_UpdateFxStatus()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mock2ndView = mockView.As<ISecondaryFxView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            FxStatusChangeEventArgs ea = new FxStatusChangeEventArgs(FxStatus.UnInitialized, FxStatus.Validating);

            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            //Act
            _presenter._Fx_StatusChanged(mockFx.Object, ea);

            mock2ndView.Verify(m => m.UpdateFxStatus(FxStatus.Validating), Times.Once);
        }
        public void NetworkPropertiesView_FxViewClosing_Event_Subscribed_To_When_View_Object_Is_Set()
        {
            var mockView = new Mock<INetworkPropertiesView>();
            var mock2ndView = mockView.As<ISecondaryFxView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var mockCmpdFx = mockFx.As<ICompoundFx>();
            var args = new ViewActionEventArgs();

            mockCmpdFx.Setup(m => m.Cancel()).Verifiable();

            //Act
            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;
            _presenter.NetworkPropertiesView = mockView.Object;

            //Assert
            mock2ndView.Raise(m => m.FxViewClosing += null, args);
            mockCmpdFx.Verify();
        }
        public void _Fx_CoreModified_EventHandler_Calls_View_SetPropertiesText(CoreActions modelAction)
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var ea = new CoreModifiedEventArgs() { ModelAction = modelAction };
            mockFx.Setup(m => m.Properties).Returns("Blah");

            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            //Act
            _presenter._Fx_CoreModified(mockFx.Object, ea);

            //Assert
            mockView.Verify(m => m.SetPropertiesText("Blah"), Times.Once);
        }
        public void _Fx_CoreModified_Does_Not_Call_View_SetPropertiesText_If_Sender_Is_Null()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var mockCmpdFx = mockFx.As<ICompoundFx>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;

            //Act
            _presenter._Fx_CoreModified(null, new CoreModifiedEventArgs());

            //Assert
            mockView.Verify(m => m.SetPropertiesText("Blah"), Times.Never);
        }
        public void View_Getter_Returns_View_As_An_ISecondaryView()
        {
            var mockView = new Mock<INetworkPropertiesView>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);

            Assert.Null(_presenter.NetworkPropertiesView);
            _presenter.NetworkPropertiesView = mockView.Object;

            var actualView = _presenter.View;

            Assert.NotNull(actualView);
            Assert.Same(mockView.Object, actualView);
        }
        public void NetworkPropertiesView_Gets_And_Sets_Vew()
        {
            var mockView = new Mock<INetworkPropertiesView>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);
            Assert.Null(_presenter.NetworkPropertiesView);
            _presenter.NetworkPropertiesView = mockView.Object;

            ISecondaryFxView actualView = _presenter.NetworkPropertiesView;

            Assert.NotNull(actualView);
            Assert.Same(mockView.Object, actualView);
        }
        public void NetworkPropertiesView_FxViewClosing_Event_UnSubscribed_From_When_View_Object_Is_Set_To_Null_From_Non_Null()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mock2ndView = mockView.As<ISecondaryFxView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var mockCmpdFx = mockFx.As<ICompoundFx>();
            var args = new ViewActionEventArgs();

            mockFx.Setup(m => m.Properties).Returns("Blah");

            //Act
            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;
            _presenter.NetworkPropertiesView = mockView.Object;
            _presenter.NetworkPropertiesView = null;

            //Assert
            mock2ndView.Raise(m => m.FxViewClosing += null, args);
            mockCmpdFx.Verify(m => m.Cancel(), Times.Never);
        }
        public void NetworkPropertiesFx_CoreModified_Event_Subscribed_To_When_Fx_Object_Is_Set(CoreActions modelAction)
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var args = new CoreModifiedEventArgs() { ModelAction = modelAction };

            mockFx.Setup(m => m.Properties).Returns("Blah");
            mockView.Setup(m => m.SetPropertiesText("Blah")).Verifiable();

            //Act
            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;
            _presenter.NetworkPropertiesView = mockView.Object;

            //Assert
            mockFx.Raise(m => m.CoreModified += null, args);
            mockView.Verify();
        }
        public void NetworkPropertiesFx_CoreModified_Event_UnSubscribed_From_When_Fx_Object_Is_Set_To_Null_From_Non_Null()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var args = new CoreModifiedEventArgs();

            mockFx.Setup(m => m.Properties).Returns("Blah");

            //Act
            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;
            _presenter.NetworkPropertiesView = mockView.Object;
            _presenter.NetworkPropertiesFx = null;

            //Assert
            mockFx.Raise(m => m.CoreModified += null, args);
            mockView.Verify(m => m.SetPropertiesText("Blah"), Times.Never);
        }
        public void _Fx_CoreModified_EventHandler_Not_Implemented_For_Other_Actions(CoreActions modelAction)
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var ea = new CoreModifiedEventArgs() { ModelAction = modelAction };

            _presenter = new NetworkPropertiesFxPresenter(mockFx.Object, mockView.Object);

            //Act, Assert
            var ex = Assert.Throws<NotImplementedException>(() => _presenter._Fx_CoreModified(mockFx.Object, ea));
        }
        public void _Fx_StatusChanged_Does_Not_Call_View_UpdateFxStatus_If_Sender_Is_Null()
        {
            var mockView = new Mock<INetworkPropertiesView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();

            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesView = mockView.Object;

            //Act
            _presenter._Fx_StatusChanged(null, new FxStatusChangeEventArgs(FxStatus.Complete, FxStatus.Error));

            //Assert
            mockView.Verify(m => m.UpdateFxStatus(FxStatus.Error), Times.Never);
        }
        public void NetworkPropertiesFx_StatusChanged_Event_UnSubscribed_From_When_Fx_Object_Is_Set_To_Null_From_Non_Null()
        {
            //Arrange
            var mockView = new Mock<INetworkPropertiesView>();
            var mock2ndView = mockView.As<ISecondaryFxView>();
            var mockFx = new Mock<INetworkPropertiesElementFx>();
            var args = new FxStatusChangeEventArgs(FxStatus.Error, FxStatus.UnInitialized);

            //Act
            _presenter = new NetworkPropertiesFxPresenter(null, null);
            _presenter.NetworkPropertiesFx = mockFx.Object;
            _presenter.NetworkPropertiesFx = null;

            //Assert
            mockFx.Raise(m => m.StatusChanged += null, args);
            mock2ndView.Verify(m => m.UpdateFxStatus(FxStatus.UnInitialized), Times.Never);
        }