Пример #1
0
        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);
                }
        }
Пример #2
0
        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);
                }
        }
Пример #3
0
        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);
                }
        }
Пример #4
0
        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);
                }
        }
Пример #5
0
        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);
                }
        }