Beispiel #1
0
        public override void TearDown()
        {
            _mainWindowTester.Close();
            Palaso.UI.WindowsForms.Keyboarding.KeyboardController.Shutdown();
            base.TearDown();
            if (BasilProject.IsInitialized)
            {
                WeSayWordsProject.Project.Dispose();
            }

            Palaso.TestUtilities.TestUtilities.DeleteFolderThatMayBeInUse(_projectFolder);
        }
Beispiel #2
0
        public void FormClose()
        {
            MultiForm form = new MultiForm();

            form.Show();
            TestWriter   writer = new TestWriter(form);
            ButtonTester button = new ButtonTester("myButton");

            button.Click();
            FormTester form0 = new FormTester("Form-0");

            form0.Close();

            Assert.AreEqual(
                @"[Test]
public void Test()
{

	ButtonTester myButton = new ButtonTester(""myButton"");
	FormTester Form-0 = new FormTester(""Form-0"");

	myButton.Click();
	Form-0.Close();

}",
                writer.Test);
        }
Beispiel #3
0
        public void ShowDialog_TestDialog_CancelButtonSet()
        {
            // Setup
            var mocks  = new MockRepository();
            var window = mocks.StrictMock <IWin32Window>();

            window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            Icon icon = IconStub();

            DialogBoxHandler = (name, wnd) =>
            {
                var openedDialog = new FormTester(name);

                openedDialog.Close();
            };

            using (var dialog = new TestDialog(window, icon, 1, 2))
            {
                // Call
                dialog.ShowDialog();

                // Assert
                Assert.IsNotNull(dialog.CancelButton);
                Assert.AreSame("Test button", ((Button)dialog.CancelButton).Name);
            }

            mocks.VerifyAll();
        }
Beispiel #4
0
        public void ShowDialog_TestDialog_MinimumSizeSet()
        {
            // Setup
            var mocks  = new MockRepository();
            var window = mocks.StrictMock <IWin32Window>();

            window.Expect(w => w.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            Icon icon = IconStub();

            DialogBoxHandler = (name, wnd) =>
            {
                var openedDialog = new FormTester(name);

                openedDialog.Close();
            };

            using (var dialog = new TestDialog(window, icon, 1, 2))
            {
                // Call
                dialog.ShowDialog();

                // Assert
                Assert.AreEqual(1, dialog.MinimumSize.Width);
                Assert.AreEqual(2, dialog.MinimumSize.Height);
            }

            mocks.VerifyAll();
        }
Beispiel #5
0
        private void CloseR440O()
        {
            Thread.Sleep(2000);
            var formTester = new FormTester("R440OForm");

            formTester.Close();
        }
Beispiel #6
0
        public void TestUsingOpenProject()
        {
            FormTester AdminWindow = new FormTester("WeSay Admin");

            ToolStripMenuItemTester projectToolStripMenuItem =
                new ToolStripMenuItemTester("projectToolStripMenuItem");
            ToolStripMenuItemTester newProjectToolStripMenuItem =
                new ToolStripMenuItemTester("newProjectToolStripMenuItem");

            projectToolStripMenuItem.Click();
            //       ExpectModal("Browse For Folder", "ClickOKInFileDialog", true);

            newProjectToolStripMenuItem.Click();

            AdminWindow.Close();
        }
        public void ExportFrom_MultipleSupportedExportersAvailableWithDefaultSelectionDialogStyling_GivesExpectedSelectionDialog()
        {
            // Setup
            var mockRepository = new MockRepository();
            var mainWindow     = mockRepository.Stub <IMainWindow>();

            mockRepository.ReplayAll();

            var dialogText = "";

            TestListViewItem[] listViewItems = null;

            ModalFormHandler = (name, wnd, form) =>
            {
                var dialog    = new FormTester(name);
                var imageList = TypeUtils.GetField <ImageList>(dialog.TheObject, "imageList");
                var listView  = (ListView) new ControlTester("listViewItemTypes").TheObject;

                dialogText    = dialog.Text;
                listViewItems = listView.Items
                                .OfType <ListViewItem>()
                                .Select(lvi => new TestListViewItem(lvi.Name, lvi.Group.Name, imageList.Images[lvi.ImageIndex]))
                                .ToArray();

                dialog.Close();
            };

            var exportHandler = new GuiExportHandler(mainWindow, new List <ExportInfo>
            {
                new ExportInfo <int>(),
                new ExportInfo <int>()
            });

            // Call
            exportHandler.ExportFrom(1234);

            // Assert
            Assert.AreEqual("Kies wat u wilt exporteren", dialogText);

            Assert.AreEqual(2, listViewItems.Length);
            Assert.AreEqual("", listViewItems[0].Name);
            Assert.AreEqual("Algemeen", listViewItems[0].Group);
            Assert.AreEqual("", listViewItems[1].Name);
            Assert.AreEqual("Algemeen", listViewItems[1].Group);

            mockRepository.VerifyAll();
        }
Beispiel #8
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.True(myButton.Properties.Visible);
                    form.Close();

                    Assert.Throws <NoSuchControlException>(delegate {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                    });
                }
            }
        }
Beispiel #9
0
        public static void PatSearchDlg_Handler(string name, IntPtr ptr, Form form)
        {
            var tabs = new TabControlTester("tabsTools", form);

            EnterNumeric("edMinGens", form, 1);

            ClickButton("btnPatSearch", form);

            ClickButton("btnSetPatriarch", form);

            ClickButton("btnPatriarchsDiagram", form);
            var pvWin = new FormTester("PatriarchsViewerWin");

            pvWin.Close();

            form.Close();
        }
Beispiel #10
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.True(myButton.Properties.Visible);
                    form.Close();

                    Assert.Throws<NoSuchControlException>(delegate {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                    });
                }
            }
        }
Beispiel #11
0
        public void ShowDetailsButton_MessageSelectedOnDoubleClick_ShowMessageWindowDialogWithDetails()
        {
            // Setup
            var mocks        = new MockRepository();
            var dialogParent = mocks.Stub <IWin32Window>();

            mocks.ReplayAll();
            const string detailedMessage = "TestDetailedMessage";

            using (var form = new Form())
                using (MessageWindow messageWindow = ShowMessageWindow(dialogParent))
                {
                    form.Controls.Add(messageWindow);
                    form.Show();

                    string dialogTitle = null;
                    string dialogText  = null;

                    DialogBoxHandler = (name, wnd) =>
                    {
                        var dialogTester = new FormTester(name);
                        dialogTitle = ((Form)dialogTester.TheObject).Text;
                        var testBoxTester = new TextBoxTester("textBox");
                        dialogText = testBoxTester.Text;
                        dialogTester.Close();
                    };

                    var gridView = new ControlTester("messagesDataGridView");
                    messageWindow.AddMessage(Level.Warn, new DateTime(), detailedMessage);
                    messageWindow.Refresh();

                    // Call
                    gridView.FireEvent("CellMouseDoubleClick", new DataGridViewCellMouseEventArgs(
                                           0, 0, 0, 0,
                                           new MouseEventArgs(MouseButtons.Left, 2, 0, 0, 0)));

                    // Assert
                    Assert.AreEqual("Berichtdetails", dialogTitle);
                    Assert.AreEqual(detailedMessage, dialogText);
                }

            mocks.VerifyAll();
        }
Beispiel #12
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.IsTrue(myButton.Properties.Visible);
                    form.Close();

                    try
                    {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                        Assert.Fail("found control after closing form");
                    }
                    catch (NoSuchControlException) {}
                }
            }
        }
Beispiel #13
0
        public void Close()
        {
            using (MultiForm formMultiForm = new MultiForm())
            {
                formMultiForm.Show();
                ButtonTester myButton = new ButtonTester("myButton");
                using (FormTester form = new FormTester("Form"))
                {
                    Assert.IsTrue(myButton.Properties.Visible);
                    form.Close();

                    try
                    {
                        bool shouldNotGetMe = myButton.Properties.Visible;
                        Assert.Fail("found control after closing form");
                    }
                    catch (NoSuchControlException) {}
                }
            }
        }
Beispiel #14
0
        public void ShowDetailsButton_MessageSelectedOnClick_ShowMessageWindowDialogWithDetails()
        {
            // Setup
            var mocks        = new MockRepository();
            var dialogParent = mocks.Stub <IWin32Window>();

            mocks.ReplayAll();

            const string detailedMessage = "TestDetailedMessage";

            using (var form = new Form())
                using (MessageWindow messageWindow = ShowMessageWindow(dialogParent))
                {
                    form.Controls.Add(messageWindow);
                    form.Show();

                    string dialogTitle = null;
                    string dialogText  = null;

                    DialogBoxHandler = (name, wnd) =>
                    {
                        var dialogTester = new FormTester(name);
                        dialogTitle = ((Form)dialogTester.TheObject).Text;
                        var testBoxTester = new TextBoxTester("textBox");
                        dialogText = testBoxTester.Text;
                        dialogTester.Close();
                    };
                    messageWindow.AddMessage(Level.Warn, new DateTime(), detailedMessage);
                    messageWindow.Refresh();
                    var buttonTester = new ToolStripButtonTester("buttonShowDetails");

                    // Call
                    buttonTester.Click();

                    // Assert
                    Assert.AreEqual("Berichtdetails", dialogTitle);
                    Assert.AreEqual(detailedMessage, dialogText);
                }

            mocks.VerifyAll();
        }
Beispiel #15
0
        public void ShowDialog_ActivityProgressDialog_MinimumSizeSet()
        {
            // Setup
            DialogBoxHandler = (name, wnd) =>
            {
                var openedDialog = new FormTester(name);

                openedDialog.Close();
            };

            using (var dialogParent = new TestViewParentForm())
                using (var dialog = new ActivityProgressDialog(dialogParent, Enumerable.Empty <Activity>()))
                {
                    // Call
                    dialog.ShowDialog();

                    // Assert
                    Assert.AreEqual(520, dialog.MinimumSize.Width);
                    Assert.AreEqual(150, dialog.MinimumSize.Height);
                }
        }
Beispiel #16
0
        public void FormClose()
        {
            MultiForm form = new MultiForm();
            form.Show();
            TestWriter writer = new TestWriter(form);
            ButtonTester button = new ButtonTester("myButton");
            button.Click();
            FormTester form0 = new FormTester("Form-0");
            form0.Close();

            Assert.AreEqual(
                    @"[Test]
            public void Test()
            {

            ButtonTester myButton = new ButtonTester(""myButton"");
            FormTester Form-0 = new FormTester(""Form-0"");

            myButton.Click();
            Form-0.Close();

            }",
                    writer.Test);
        }
        public void ExportFrom_MultipleSupportedExportersAvailableWithCustomSelectionDialogStyling_GivesExpectedSelectionDialog(bool hasFileExtension)
        {
            // Setup
            var mockRepository = new MockRepository();
            var mainWindow     = mockRepository.Stub <IMainWindow>();

            mockRepository.ReplayAll();

            var dialogText = "";

            TestListViewItem[] listViewItems = null;

            ModalFormHandler = (name, wnd, form) =>
            {
                var dialog    = new FormTester(name);
                var imageList = TypeUtils.GetField <ImageList>(dialog.TheObject, "imageList");
                var listView  = (ListView) new ControlTester("listViewItemTypes").TheObject;

                dialogText    = dialog.Text;
                listViewItems = listView.Items
                                .OfType <ListViewItem>()
                                .Select(lvi => new TestListViewItem(lvi.Name, lvi.Group.Name, imageList.Images[lvi.ImageIndex]))
                                .ToArray();

                dialog.Close();
            };

            var exportInfo1 = new ExportInfo <int>
            {
                Name      = i => "Name 1",
                Category  = "Category 1",
                Image     = Resources.Busy_indicator,
                Extension = hasFileExtension ? "extension 1" : null
            };

            var exportInfo2 = new ExportInfo <int>
            {
                Name      = i => "Name 2",
                Category  = "Category 2",
                Image     = Resources.DeleteIcon,
                Extension = hasFileExtension ? "extension 2" : null
            };

            var exportHandler = new GuiExportHandler(mainWindow, new List <ExportInfo>
            {
                exportInfo1,
                exportInfo2
            });

            // Call
            exportHandler.ExportFrom(1234);

            // Assert
            Assert.AreEqual("Kies wat u wilt exporteren", dialogText);

            Assert.AreEqual(2, listViewItems.Length);
            string exportInfo1Name   = exportInfo1.Name(1234);
            string expectedItemName1 = hasFileExtension
                                           ? $"{exportInfo1Name} (*.{exportInfo1.Extension})"
                                           : exportInfo1Name;

            Assert.AreEqual(expectedItemName1, listViewItems[0].Name);
            Assert.AreEqual(exportInfo1.Category, listViewItems[0].Group);
            string exportInfo2Name   = exportInfo2.Name(1234);
            string expectedItemName2 = hasFileExtension
                                           ? $"{exportInfo2Name} (*.{exportInfo2.Extension})"
                                           : exportInfo2Name;

            Assert.AreEqual(expectedItemName2, listViewItems[1].Name);
            Assert.AreEqual(exportInfo2.Category, listViewItems[1].Group);

            mockRepository.VerifyAll();
        }