Ejemplo n.º 1
0
        private static void AbreArchivo(string elArchivo)
        {
            // Crea el camino absoluto al archivo.
            string archivoParaAbrir = Path.Combine(miDirectorioDeData, elArchivo);

            archivoParaAbrir = Path.GetFullPath(archivoParaAbrir);

            // Instala un manejador que espere por la ventana de abrir archivo.
            using (ModalFormTester probadorDeForma = new ModalFormTester())
            {
                probadorDeForma.ExpectModal("Open", delegate
                {
                    OpenFileDialogTester formaAbrirArchivo = new OpenFileDialogTester("Open");

                    // Manda a abrir el arhivo.
                    // Por alguna razón desconocida, la llamada a OpenFile a veces no
                    // funciona. Llamamos la misma función 10 veces para
                    // asegurarnos que funciona.
                    for (int i = 0; i < 10; ++i)
                    {
                        formaAbrirArchivo.OpenFile(archivoParaAbrir);
                        Thread.Sleep(100);
                    }
                }
                                            );

                // Selecciona el menú de abrir archivo.
                ToolStripMenuItemTester menuAbrirArchivo = new ToolStripMenuItemTester("miMenuAbrirArchivo");
                menuAbrirArchivo.Click();
            }
        }
        public void PersonListView_ShowWarning_ShowsMessageBoxWithCorrectTitleAndMessage()
        {
            // Arrange
            string title   = string.Empty;
            string message = string.Empty;

            ClientServiceLocator.PersonListPresenter = new FakePersonListPresenter();
            PersonListView view = new PersonListView();

            MessageBoxTester messageTester = null;

            ModalFormTester messageBoxTester = new ModalFormTester();

            messageBoxTester.ExpectModal("Test Title", new ModalFormActivated(delegate { messageTester = new MessageBoxTester("Test Title");
                                                                                         title         = messageTester.Title;
                                                                                         message       = messageTester.Text;
                                                                                         messageTester.ClickOk(); }));
            // Act
            view.ShowWarning("Test Title", "Test Message");

            // Assert
            Assert.IsTrue(messageBoxTester.Verify(), "MessageBox not shown");
            Assert.AreEqual("Test Title", title, "Title not correct");
            Assert.AreEqual("Test Message", message, "Message not correct");
        }
Ejemplo n.º 3
0
        public void Application_CreateProject_DoesNotCrash()
        {
            CreateProject();

            // Add new session.
            var idTextBoxTester = AddItem("SessionEditor", "_sessionsListPanel");

            // Add a component file to the session.
            var filePath = Path.Combine(_projectsFolder.Path, "dummyFile.png");

            (new Bitmap(1, 1)).Save(filePath);

            var componentGrid = _projectContext.ProjectWindow.Controls.Find(
                "_sessionComponentFileGrid", true)[0] as ComponentFileGrid;

            // Can't add the file via clicking the add button because we cannot control the
            // open file dialog box unless this class were to derive from NUnitFormTest, but
            // that causes other problems.
            componentGrid.FilesAdded(new[] { filePath });
            Assert.AreEqual("dummyFile.png", componentGrid.Grid[1, 1].Value as string);

            var listPanel = GetListPanelByName("_sessionsListPanel");
            var list      = listPanel.ListControl as ElementGrid;

            // Rename the session.
            idTextBoxTester.Enter("RenamedSession");
            idTextBoxTester.FireEvent("Validating", new CancelEventArgs());
            Assert.AreEqual("RenamedSession", idTextBoxTester.Text);
            Assert.AreEqual("RenamedSession", list.GetCurrentElement().Id);
            Assert.AreEqual("RenamedSession.session", componentGrid.Grid[1, 0].Value as string);

            // Delete the session.
            DeleteItems(listPanel, "SessionListScreen");
            Assert.AreEqual(0, list.RowCount);

            // Open the dialog to add files from a device, then cancel it.
            using (var modalFormTester = new ModalFormTester())
            {
                var cancelButtonTester = new ButtonTester("_buttonCancel");
                modalFormTester.ExpectModal("NewSessionsFromFilesDlg", cancelButtonTester.Click);
                var newButtonTester = new ButtonTester("_buttonNewFromFiles");
                newButtonTester.Click();
            }

            ClickPeopleTab();

            // Add a new person.
            listPanel       = GetListPanelByName("_peopleListPanel");
            list            = listPanel.ListControl as ElementGrid;
            idTextBoxTester = AddItem("PersonEditor", "_peopleListPanel");

            // Delete the person.
            DeleteItems(listPanel, "PersonListScreen");
            Assert.AreEqual(0, list.RowCount);
        }
Ejemplo n.º 4
0
        public void Execute_LaunchAndClose_DoesNotCrash()
        {
            var tester       = new ModalFormTester();
            var buttonTester = new ButtonTester("_okButton");

            tester.ExpectModal("ShowReleaseNotesDialog", () => buttonTester.FireEvent("Click"));
            var cmd = new ReleaseNotesCommand();

            cmd.Execute();
            tester.Verify();
        }
Ejemplo n.º 5
0
 //[Test]
 public void CompleteExampleWithoutBaseClass() //still not promising to clean up EVERYTHING
 {
     using (new Desktop())
     {
         using (new FormTester("Form"))
         {
             using (ModalFormTester modalTester = new ModalFormTester())
             {
                 modalTester.FormHandler = ModalFormHandler;
                 new ModalMultiForm().Show();
                 new ButtonTester("myButton", "Form").Click();
             }
         }
     }
 }
 //still not promising to clean up EVERYTHING
 //[Fact]
 public void CompleteExampleWithoutBaseClass()
 {
     using (new Desktop())
     {
         using (new FormTester("Form"))
         {
             using (ModalFormTester modalTester = new ModalFormTester())
             {
                 modalTester.FormHandler = ModalFormHandler;
                 new ModalMultiForm().Show();
                 new ButtonTester("myButton", "Form").Click();
             }
         }
     }
 }
        //this is a working test by itself, but it is not on hidden desktop without base class.
        //so i called this method from another test that uses the desktop
        //[Test]
        public void ModalFormExample()
        {
            using(ModalFormTester tester = new ModalFormTester())
            {
                tester.ExpectModal("Form-0", new ModalFormActivated(ModalFormHandler));

                //using (ModalMultiForm form = new ModalMultiForm())
                //{
                //    ////    form.Show();

                //    ////    new ButtonTester("myButton", "Form").Click();

                //    ////    form.Close();
                //}
            }
        }
Ejemplo n.º 8
0
        //this is a working test by itself, but it is not on hidden desktop without base class.
        //so i called this method from another test that uses the desktop
        //[Test]
        public void ModalFormExample()
        {
            using (ModalFormTester tester = new ModalFormTester())
            {
                tester.FormHandler = ModalFormHandler;

                //using (ModalMultiForm form = new ModalMultiForm())
                //{
                //    ////    form.Show();

                //    ////    new ButtonTester("myButton", "Form").Click();

                //    ////    form.Close();
                //}
            }
        }
        //this is a working test by itself, but it is not on hidden desktop without base class.
        //so i called this method from another test that uses the desktop
        //[Test]
        public void ModalFormExample()
        {
            using (ModalFormTester tester = new ModalFormTester())
            {
                tester.ExpectModal("Form-0", new ModalFormActivated(ModalFormHandler));

                //using (ModalMultiForm form = new ModalMultiForm())
                //{
                //    ////    form.Show();

                //    ////    new ButtonTester("myButton", "Form").Click();

                //    ////    form.Close();
                //}
            }
        }
        //this is a working test by itself, but it is not on hidden desktop without base class.
        //so i called this method from another test that uses the desktop
        //[Fact]
        public void ModalFormExample()
        {
            using (ModalFormTester tester = new ModalFormTester())
            {
                tester.FormHandler = ModalFormHandler;

                //using (ModalMultiForm form = new ModalMultiForm())
                //{
                //    ////    form.Show();

                //    ////    new ButtonTester("myButton", "Form").Click();

                //    ////    form.Close();
                //}
            }
        }
Ejemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Deletes all the sessions, or all the people.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private static void DeleteItems(ListPanel listPanel, string screenName)
        {
            using (var modalFormTester = new ModalFormTester())
            {
                var list = listPanel.ListControl as ElementGrid;
                int maxDeleteAttempts = 100;
                var delButtonTester   = new ButtonTester("deleteBtn", "ConfirmRecycleDialog");

                while (list.RowCount > 0)
                {
                    list.SelectElement(0);
                    modalFormTester.ExpectModal("ConfirmRecycleDialog", delButtonTester.Click);
                    list.DeleteAction();

                    if (--maxDeleteAttempts == 0)
                    {
                        throw new Exception(string.Format("Deleting items from {0} failed.", screenName));
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// ------------------------------------------------------------------------------------
        private void CreateProject()
        {
            using (var modalFormTester = new ModalFormTester())
            {
                var createButtonTester = new ToolStripButtonTester("_buttonCreate");
                var nameTextBoxTester  = new TextBoxTester("_textBoxName");
                var okButtonTester     = new ButtonTester("_buttonOK");

                modalFormTester.ExpectModal("WelcomeDialog", createButtonTester.Click);
                modalFormTester.ExpectModal("NewProjectDlg", () =>
                {
                    nameTextBoxTester.Properties.Text = "Boring New Project Name";
                    okButtonTester.Click();
                });

                using (var dlg = _applicationContainer.CreateWelcomeDialog())
                {
                    dlg.ShowDialog();
                    SetupProjectWindow(dlg.Model.ProjectSettingsFilePath);
                }
            }
        }