public void GivenValidDialog_WhenCancelPressed_ThenWmtsConnectionDataNull()
        {
            // Given
            Button cancelButton = null;

            DialogBoxHandler = (name, wnd) =>
            {
                using (new FormTester(name))
                {
                    var button = new ButtonTester("cancelButton", name);
                    cancelButton = (Button)button.TheObject;
                    button.Click();
                }
            };

            using (var dialogParent = new Form())
                using (var dialog = new WmtsConnectionDialog(dialogParent))
                {
                    // When
                    DialogResult dialogResult = dialog.ShowDialog();

                    // Then
                    Assert.IsNull(dialog.WmtsConnectionName);
                    Assert.IsNull(dialog.WmtsConnectionUrl);

                    Assert.AreEqual(dialog.CancelButton, cancelButton);
                    Assert.AreEqual(DialogResult.Cancel, dialogResult);
                }
        }
        public void ActionButtonCick_WithValidText_SetsPropertiesAndClosesForm()
        {
            // Setup
            const string urltextbox  = @"urlTextBox";
            const string nametextbox = @"nameTextBox";

            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName))
                {
                    var nameTextBox = (TextBox) new TextBoxTester("nameTextBox", formName).TheObject;
                    var urlTextBox  = (TextBox) new TextBoxTester("urlTextBox", formName).TheObject;
                    nameTextBox.Text = nametextbox;
                    urlTextBox.Text  = urltextbox;

                    var actionButton = new ButtonTester("actionButton", formName);

                    // Call
                    actionButton.Click();
                }
            };

            using (var dialogParent = new Form())
                using (var dialog = new WmtsConnectionDialog(dialogParent))
                {
                    DialogResult dialogResult = dialog.ShowDialog();

                    // Assert
                    Assert.AreEqual(nametextbox, dialog.WmtsConnectionName);
                    Assert.AreEqual(urltextbox, dialog.WmtsConnectionUrl);
                    Assert.AreEqual(DialogResult.OK, dialogResult);
                }
        }
        public void ActionButton_WithoutValidText_ButtonIsDisabled(
            [Values("", "  ", null)] string name,
            [Values("", "  ", null)] string url)
        {
            // Setup
            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName)) {}
            };

            using (var dialogParent = new Form())
                using (var dialog = new WmtsConnectionDialog(dialogParent))
                {
                    dialog.ShowDialog();

                    var nameTextBox  = (TextBox) new TextBoxTester("nameTextBox", dialog).TheObject;
                    var urlTextBox   = (TextBox) new TextBoxTester("urlTextBox", dialog).TheObject;
                    var actionButton = (Button) new ButtonTester("actionButton", dialog).TheObject;

                    // Call
                    nameTextBox.Text = name;
                    urlTextBox.Text  = url;

                    // Assert
                    Assert.IsFalse(actionButton.Enabled);
                }
        }
        public void ActionButton_WithValidText_ButtonIsEnabled()
        {
            // Setup
            DialogBoxHandler = (formName, wnd) =>
            {
                using (new FormTester(formName)) {}
            };

            using (var dialogParent = new Form())
                using (var dialog = new WmtsConnectionDialog(dialogParent))
                {
                    dialog.ShowDialog();

                    var nameTextBox  = (TextBox) new TextBoxTester("nameTextBox", dialog).TheObject;
                    var urlTextBox   = (TextBox) new TextBoxTester("urlTextBox", dialog).TheObject;
                    var actionButton = (Button) new ButtonTester("actionButton", dialog).TheObject;

                    // Call
                    nameTextBox.Text = @"nameTextBox";
                    urlTextBox.Text  = @"urlTextBox";

                    // Assert
                    Assert.IsTrue(actionButton.Enabled);
                }
        }
        public void ShowDialog_DefaultProperties()
        {
            // Setup
            DialogBoxHandler = (name, wnd) =>
            {
                using (new FormTester(name)) {}
            };

            using (var dialogParent = new Form())
                using (var dialog = new WmtsConnectionDialog(dialogParent))
                {
                    // Call
                    dialog.ShowDialog();

                    // Assert
                    Assert.AreEqual(400, dialog.MinimumSize.Width);
                    Assert.AreEqual(150, dialog.MinimumSize.Height);
                }
        }