public void FahClientSettingsPresenter_ConnectClicked_AttemptsConnectionAndShowsMessageBoxOnFailure() { // Arrange var messageBox = new MockMessageBoxPresenter(); using (var presenter = new MockDialogFahClientSettingsPresenter(new FahClientSettingsModel { Name = "foo", Server = "bar" }, messageBox)) { // Act presenter.ConnectClicked(); // Assert Assert.AreEqual(1, messageBox.Invocations.Count); } }
public void FahClientSettingsPresenter_ConnectClicked_ConnectsWhenModelHasNoError() { // Arrange using (var connection = new MockFahClientConnectionWithMessages()) { var model = new MockConnectionFahClientSettingsModel(connection) { Name = "foo", Server = "bar" }; using (var presenter = new MockDialogFahClientSettingsPresenter(model)) { // Act presenter.ConnectClicked(); // Assert Assert.IsNotNull(presenter.Connection); Assert.IsTrue(presenter.Connection.Connected); Assert.AreEqual(1, presenter.Model.Slots.Count); } } }
public void FahClientSettingsPresenter_ConnectClicked_ConnectsAndShowsMessageBoxWhenFahClientReaderFailsToRead() { // Arrange var messageBox = new MockMessageBoxPresenter(); using (var connection = new MockFahClientConnection()) { var model = new MockConnectionFahClientSettingsModel(connection) { Name = "foo", Server = "bar" }; using (var presenter = new MockDialogFahClientSettingsPresenter(model, messageBox)) { // Act presenter.ConnectClicked(); // Assert Assert.AreEqual(1, messageBox.Invocations.Count); Assert.IsNotNull(presenter.Connection); Assert.IsFalse(presenter.Connection.Connected); Assert.IsTrue(presenter.Model.ConnectEnabled); Assert.AreEqual(0, presenter.Model.Slots.Count); } } }