Exemplo n.º 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);
                }
        }
Exemplo n.º 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);
                }
        }
Exemplo n.º 3
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);
                }
        }
Exemplo n.º 4
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);
                }
        }
Exemplo n.º 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);
                }
        }
Exemplo n.º 6
0
        public void WmtsConnectionInfoConstructor_WithDialogParent_ExpectedProperties()
        {
            // Setup
            var mocks        = new MockRepository();
            var dialogParent = mocks.StrictMock <IWin32Window>();

            mocks.ReplayAll();
            const string connectionName = @"name";
            const string connectionUrl  = @"url";
            var          info           = new WmtsConnectionInfo(connectionName, connectionUrl);

            // Call
            using (var dialog = new WmtsConnectionDialog(dialogParent, info))
            {
                // Assert
                Assert.IsInstanceOf <DialogBase>(dialog);
                Assert.IsNull(dialog.WmtsConnectionName);
                Assert.IsNull(dialog.WmtsConnectionUrl);

                Assert.AreEqual("WMTS locatie aanpassen", dialog.Text);

                var nameLabel = new LabelTester("nameLabel", dialog);
                Assert.AreEqual("Omschrijving:", nameLabel.Text);

                var urlLabel = new LabelTester("urlLabel", dialog);
                Assert.AreEqual("URL:", urlLabel.Text);

                var actionButton = (Button) new ButtonTester("actionButton", dialog).TheObject;
                Assert.AreEqual("Opslaan", actionButton.Text);
                Assert.IsTrue(actionButton.Enabled);

                var cancelButton = new ButtonTester("cancelButton", dialog);
                Assert.AreEqual("Annuleren", cancelButton.Text);

                var nameTextBox = new TextBoxTester("nameTextBox", dialog);
                Assert.AreEqual(connectionName, nameTextBox.Text);

                var urlTextBox = new TextBoxTester("urlTextBox", dialog);
                Assert.AreEqual(connectionUrl, urlTextBox.Text);
            }

            mocks.VerifyAll();
        }
Exemplo n.º 7
0
        public void Dispose_AlreadyDisposed_DoesNotThrowException()
        {
            // Setup
            var mocks        = new MockRepository();
            var dialogParent = mocks.StrictMock <IWin32Window>();

            mocks.ReplayAll();

            // Call
            TestDelegate call = () =>
            {
                using (var control = new WmtsConnectionDialog(dialogParent))
                {
                    control.Dispose();
                }
            };

            // Assert
            Assert.DoesNotThrow(call);
            mocks.VerifyAll();
        }