public void FahClientSettingsPresenter_ShowDialog_DoesNotConnectWhenModelHasError() { // Arrange using (var presenter = new MockDialogFahClientSettingsPresenter(new FahClientSettingsModel())) { // Act presenter.ShowDialog(null); // Assert Assert.IsNull(presenter.Connection); } }
public void FahClientSettingsPresenter_ShowDialog_AttemptsConnectionWhenModelHasNoError() { // Arrange using (var presenter = new MockDialogFahClientSettingsPresenter(new FahClientSettingsModel { Name = "foo", Server = "bar" })) { // Act presenter.ShowDialog(null); // Assert Assert.IsNotNull(presenter.Connection); Assert.IsFalse(presenter.Connection.Connected); } }
public void FahClientSettingsPresenter_OKClicked_SetsDialogResultAndClosesDialogWhenModelHasNoError() { // Arrange using (var presenter = new MockDialogFahClientSettingsPresenter(new FahClientSettingsModel { Name = "foo", Server = "bar" })) { presenter.ShowDialog(null); Assert.IsTrue(presenter.MockDialog.Shown); // Act presenter.OKClicked(); // Assert Assert.AreEqual(DialogResult.OK, presenter.Dialog.DialogResult); Assert.IsFalse(presenter.MockDialog.Shown); } }
public void FahClientSettingsPresenter_OKClicked_ShowsMessageBoxWhenModelHasError() { // Arrange var messageBox = new MockMessageBoxPresenter(); using (var presenter = new MockDialogFahClientSettingsPresenter(new FahClientSettingsModel(), messageBox)) { presenter.ShowDialog(null); Assert.IsTrue(presenter.MockDialog.Shown); // Act presenter.OKClicked(); // Assert Assert.AreEqual(1, messageBox.Invocations.Count); Assert.IsTrue(presenter.MockDialog.Shown); } }
public void FahClientSettingsPresenter_ShowDialog_ConnectsWhenModelHasNoError() { // Arrange using (var connection = new MockFahClientConnectionWithMessages()) { var model = new MockConnectionFahClientSettingsModel(connection) { Name = "foo", Server = "bar" }; using (var presenter = new MockDialogFahClientSettingsPresenter(model)) { // Act presenter.ShowDialog(null); // Assert Assert.IsNotNull(presenter.Connection); Assert.IsTrue(presenter.Connection.Connected); Assert.AreEqual(1, presenter.Model.Slots.Count); } } }