Beispiel #1
0
        public void ButtonShowError_ButtonUnchecked_FiltersErrorMessages()
        {
            // Setup
            using (var form = new Form())
                using (MessageWindow messageWindow = ShowMessageWindow(null))
                {
                    form.Controls.Add(messageWindow);
                    form.Show();

                    AddMessages(messageWindow);
                    var dataGridView = (DataGridView) new ControlTester("messagesDataGridView").TheObject;
                    var button       = new ToolStripButtonTester("buttonShowError");

                    // Call
                    button.Click();

                    // Assert
                    Assert.IsFalse(((ToolStripButton)button.TheObject).Checked);
                    Assert.AreEqual(2, dataGridView.Rows.Count);
                    string filteredLevel = Level.Error.ToString();
                    foreach (DataGridViewRow row in dataGridView.Rows)
                    {
                        Assert.AreNotEqual(filteredLevel, row.Cells[0].Value.ToString());
                    }
                }
        }
Beispiel #2
0
//        /// <summary>
//        /// simple test to create a batch and save it
//        /// </summary>
//        [Test]
//        public void TestCreateBatchAndSave()
//        {
//            TFrmGiftBatch frmBatch = new TFrmGiftBatch(IntPtr.Zero);
//
//            frmBatch.LedgerNumber = FLedgerNumber;
//            frmBatch.Show();
//
//            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");
//            ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew");
//
//            Assert.AreEqual(false, btnSave.Properties.Enabled, "Save button should be disabled since there are no changes");
//            btnNewBatch.Click();
//
//            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");
//            txtDetailBatchDescription.Properties.Text = "Created by test TestCreateBatchAndSave";
//
//            Assert.AreEqual(true, btnSave.Properties.Enabled, "Save button should be enabled since there was a change");
//            btnSave.Click();
//        }

        private void ImportGiftBatch(string TestFile)
        {
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                OpenFileDialogTester tester = new OpenFileDialogTester(hWnd);

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat          = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "MM/dd/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;
                    ComboBoxTester cmbNumberFormat = new ComboBoxTester("cmbNumberFormat");
                    cmbNumberFormat.Select(0);
                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    ModalFormHandler = delegate(string name3, IntPtr hWnd3, Form form3)
                    {
                        MessageBoxTester tester3 = new MessageBoxTester(hWnd3);
                        Assert.AreEqual("Success", tester3.Title);
                        tester3.SendCommand(MessageBoxTester.Command.OK);
                    };
                    btnOK.Click();
                };
                tester.OpenFile(TestFile);
            };

            ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches");

            btnImport.Click();
        }
Beispiel #3
0
        public void GivenMessageWindowWithRowSelected_WhenClickButtonCopy_ThenCopiesContentToClipboard()
        {
            // Given
            using (var form = new Form())
                using (new ClipboardConfig())
                    using (MessageWindow messageWindow = ShowMessageWindow(null))
                    {
                        form.Controls.Add(messageWindow);
                        form.Show();

                        messageWindow.AddMessage(Level.Warn, new DateTime(), "message");
                        messageWindow.Refresh();

                        var dataGridView = (DataGridView) new ControlTester("messagesDataGridView").TheObject;
                        dataGridView.Rows[0].Selected = true;

                        // When
                        var button = new ToolStripButtonTester("buttonCopy");
                        button.Click();

                        // Then
                        IDataObject actualDataObject = ClipboardProvider.Clipboard.GetDataObject();
                        Assert.IsTrue(actualDataObject != null && actualDataObject.GetDataPresent(DataFormats.Text));
                        var actualContent = (string)actualDataObject.GetData(DataFormats.Text);
                        Assert.AreEqual("WARN\tmessage\t00:00:00", actualContent);
                    }
        }
//        public ToolStripMenuItemTester mniFile;
//        public System.Windows.Forms.ToolStripMenuItem mniFileSave;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator0;
//        public System.Windows.Forms.ToolStripMenuItem mniFilePrint;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator1;
//        public System.Windows.Forms.ToolStripMenuItem mniClose;
//        public System.Windows.Forms.ToolStripMenuItem mniEdit;
//        public System.Windows.Forms.ToolStripMenuItem mniEditUndoCurrentField;
//        public System.Windows.Forms.ToolStripMenuItem mniEditUndoScreen;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator2;
//        public System.Windows.Forms.ToolStripMenuItem mniEditFind;
//        public System.Windows.Forms.ToolStripMenuItem mniAccounts;
//        public System.Windows.Forms.ToolStripMenuItem mniAddNewAccount;
//        public System.Windows.Forms.ToolStripMenuItem mniDeleteUnusedAccount;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator3;
//        public System.Windows.Forms.ToolStripMenuItem mniExportHierarchy;
//        public System.Windows.Forms.ToolStripMenuItem mniImportHierarchy;
//        public System.Windows.Forms.ToolStripMenuItem mniHelp;
//        public System.Windows.Forms.ToolStripMenuItem mniHelpPetraHelp;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator4;
//        public System.Windows.Forms.ToolStripMenuItem mniHelpBugReport;
//        public System.Windows.Forms.ToolStripSeparator mniSeparator5;
//        public System.Windows.Forms.ToolStripMenuItem mniHelpAboutPetra;
//        public System.Windows.Forms.ToolStripMenuItem mniHelpDevelopmentTeam;


        // Contructor which initializes the acces to all the controls on the
        // Dialog
        /// <summary>
        /// ...
        /// </summary>
        public TFrmGLAccountHierarchyTester()
        {
            mainForm = new TFrmGLAccountHierarchy(null);

            trvAccounts                      = new TTrvTreeViewTester("trvAccounts", mainForm);
            txtDetailAccountCode             = new TextBoxTester("txtDetailAccountCode", mainForm);
            cmbDetailAccountType             = new TCmbAutoCompleteTester("cmbDetailAccountType", mainForm);
            txtDetailEngAccountCodeLongDesc  = new TextBoxTester("txtDetailEngAccountCodeLongDesc", mainForm);
            txtDetailEngAccountCodeShortDesc = new TextBoxTester("txtDetailEngAccountCodeShortDesc", mainForm);

            txtDetailAccountCodeLongDesc  = new TextBoxTester("txtDetailAccountCodeLongDesc", mainForm);
            txtDetailAccountCodeShortDesc = new TextBoxTester("txtDetailAccountCodeShortDesc", mainForm);

            cmbDetailValidCcCombo      = new TCmbAutoCompleteTester("cmbDetailValidCcCombo", mainForm);
            chkDetailBankAccountFlag   = new CheckBoxTester("chkDetailBankAccountFlag", mainForm);
            chkDetailAccountActiveFlag = new CheckBoxTester("chkDetailAccountActiveFlag", mainForm);

            tbbSave                = new ToolStripButtonTester("tbbSave", mainForm);
            tbbAddNewAccount       = new ToolStripButtonTester("tbbAddNewAccount", mainForm);
            tbbDeleteUnusedAccount = new ToolStripButtonTester("tbbDeleteUnusedAccount", mainForm);
            tbbExportHierarchy     = new ToolStripButtonTester("tbbExportHierarchy", mainForm);
            tbbImportHierarchy     = new ToolStripButtonTester("tbbImportHierarchy", mainForm);

            chkDetailForeignCurrencyFlag = new CheckBoxTester("chkDetailForeignCurrencyFlag", mainForm);
            cmbDetailForeignCurrencyCode = new TCmbAutoPopulatedTester("cmbDetailForeignCurrencyCode", mainForm);


            mniClose = new ToolStripMenuItemTester("mniClose", mainForm);
        }
Beispiel #5
0
        public void MainMenuButton()
        {
            ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonOnMain");

            tester.Click();
            Assert.Equal(label1.Text, "toolStripButtonOnMain clicked");
        }
Beispiel #6
0
        public void PanelButton()
        {
            ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonInPanel");

            tester.Click();
            Assert.Equal(label1.Text, "toolStripButtonInPanel clicked");
        }
        public void CenterContainerButton()
        {
            ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonCenterInContainer");

            tester.Click();
            Assert.AreEqual(label1.Text, "toolStripButtonCenterInContainer clicked");
        }
Beispiel #8
0
        public void RightContainerButton()
        {
            ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonRightInContainer");

            tester.Click();
            Assert.Equal(label1.Text, "toolStripButtonRightInContainer clicked");
        }
        public void ToolStripTextBoxOnToolBar()
        {
            ToolStripButtonTester button_tester = new ToolStripButtonTester("toolStripButton1");

            ToolStripTextBoxTester textbox_tester = new ToolStripTextBoxTester("toolStripTextBox1");
            Assert.True(string.IsNullOrEmpty(textbox_tester.Text));

            button_tester.Click();
            Assert.True(textbox_tester.Text == "clicked");

            textbox_tester.Enter("entered text");
            Assert.True(textbox_tester.Text == "entered text");
        }
        public static void ClickToolStripButton(string name, Form form)
        {
            var tsBtn = new ToolStripButtonTester(name, form);

            if (tsBtn.Count > 1)
            {
                tsBtn[0].FireEvent("Click");
            }
            else
            {
                tsBtn.FireEvent("Click");
            }
        }
Beispiel #11
0
        public void TestCancelBatchBug121()
        {
            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            // create a new batch and save
            ToolStripButtonTester btnSave     = new ToolStripButtonTester("tbbSave");
            ButtonTester          btnNewBatch = new ButtonTester("ucoBatches.btnNew");

            btnNewBatch.Click();
            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");

            txtDetailBatchDescription.Properties.Text = "Created by test TestCancelBatchBug121";
            btnSave.Click();

            // cancel that batch. no saving necessary
            ButtonTester btnCancelBatch = new ButtonTester("ucoBatches.btnCancel");

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                Assert.AreEqual("Form Contains Invalid Data", tester.Title);

                // there is a second message box after confirming the cancellation, telling the user the cancellation was successful.
                // because the ModalFormHandler is reset after handling the first message box, we need to set up a new handler.
                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                    // Assert.AreEqual("Success", tester.Title);
                    tester2.SendCommand(MessageBoxTester.Command.Yes);
                };

                tester.SendCommand(MessageBoxTester.Command.Yes);
            };

            btnCancelBatch.Click();

            // add a new batch
            btnNewBatch.Click();
            txtDetailBatchDescription.Properties.Text = "Created by test TestCancelBatchBug121, not cancelled";

            // save: the bug caused exception "Forgot to call AcceptChanges"
            btnSave.Click();

            Assert.AreEqual(false, btnSave.Properties.Enabled, "Save button should be disabled because all changes have been saved");

            frmBatch.Close();
        }
Beispiel #12
0
        public void ToolStripTextBoxOnToolBar()
        {
            ToolStripButtonTester button_tester = new ToolStripButtonTester("toolStripButton1");

            ToolStripTextBoxTester textbox_tester = new ToolStripTextBoxTester("toolStripTextBox1");

            Assert.IsTrue(string.IsNullOrEmpty(textbox_tester.Text));

            button_tester.Click();
            Assert.IsTrue(textbox_tester.Text == "clicked");

            textbox_tester.Enter("entered text");
            Assert.IsTrue(textbox_tester.Text == "entered text");
        }
Beispiel #13
0
        public static void ClickToolStripButton(string name, Form form)
        {
            var tsBtn = new ToolStripButtonTester(name, form);

            if (tsBtn.Count > 1)
            {
                // FIXME: Find out why sometimes the search returns
                // two components where there is only one (MediaViewerWinTests)
                tsBtn[0].FireEvent("Click");
            }
            else
            {
                tsBtn.FireEvent("Click");
            }
        }
Beispiel #14
0
        public void ShowDetailsButton_NoMessageSelectedOnClick_DoNotShowMessageWindowDialog()
        {
            // Setup
            using (var form = new Form())
                using (MessageWindow messageWindow = ShowMessageWindow(null))
                {
                    form.Controls.Add(messageWindow);
                    form.Show();

                    var button = new ToolStripButtonTester("buttonShowDetails");

                    // Call
                    button.Click();

                    // Assert
                    // No dialog window shown
                }
        }
Beispiel #15
0
        public void TestCreateBatchAndSave()
        {
            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            ToolStripButtonTester btnSave     = new ToolStripButtonTester("tbbSave");
            ButtonTester          btnNewBatch = new ButtonTester("ucoBatches.btnNew");

            Assert.AreEqual(false, btnSave.Properties.Enabled, "Save button should be disabled since there are no changes");
            btnNewBatch.Click();

            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");

            txtDetailBatchDescription.Properties.Text = "Created by test TestCreateBatchAndSave";

            Assert.AreEqual(true, btnSave.Properties.Enabled, "Save button should be enabled since there was a change");
            btnSave.Click();
        }
        private TFrmGLCreateLedgerTester()
        {
            TFrmGLCreateLedgerDialog = new TFrmGLCreateLedgerDialog(null);

            nudLedgerNumber = new NumericUpDownTester("nudLedgerNumber", TFrmGLCreateLedgerDialog);

            txtLedgerName = new TextBoxTester("txtLedgerName", TFrmGLCreateLedgerDialog);

            cmbCountryCode  = new TCmbAutoPopulatedTester("cmbCountryCode", TFrmGLCreateLedgerDialog);
            cmbBaseCurrency = new TCmbAutoPopulatedTester("cmbBaseCurrency", TFrmGLCreateLedgerDialog);
            cmbIntlCurrency = new TCmbAutoPopulatedTester("cmbIntlCurrency", TFrmGLCreateLedgerDialog);

            // TextBoxTester dtpCalendarStartDate = new TextBoxTester("dtpCalendarStartDate", TFrmGLCreateLedgerDialog);

            nudNumberOfPeriods           = new NumericUpDownTester("nudNumberOfPeriods", TFrmGLCreateLedgerDialog);
            nudCurrentPeriod             = new NumericUpDownTester("nudCurrentPeriod", TFrmGLCreateLedgerDialog);
            nudNumberOfFwdPostingPeriods = new NumericUpDownTester("nudNumberOfFwdPostingPeriods", TFrmGLCreateLedgerDialog);

            tbbCreate = new ToolStripButtonTester("tbbCreate", TFrmGLCreateLedgerDialog);
        }
Beispiel #17
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 #18
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);
                }
            }
        }
Beispiel #19
0
        public void ButtonClearAll_Click_RemovesAllMessages()
        {
            // Setup
            using (var form = new Form())
                using (MessageWindow messageWindow = ShowMessageWindow(null))
                {
                    form.Controls.Add(messageWindow);
                    form.Show();

                    messageWindow.AddMessage(Level.Warn, new DateTime(), "message");
                    messageWindow.Refresh();
                    var dataGridView = (DataGridView) new ControlTester("messagesDataGridView").TheObject;

                    var button = new ToolStripButtonTester("buttonClearAll");

                    // Call
                    button.Click();

                    // Assert
                    Assert.AreEqual(0, dataGridView.Rows.Count);
                }
        }
 public void RightContainerButton()
 {
     ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonRightInContainer");
     tester.Click();
     Assert.Equal(label1.Text, "toolStripButtonRightInContainer clicked");
 }
Beispiel #21
0
        public void TestAnalysisAttributes()
        {
            // At the moment the initial state is unknown so we make a relative test


            TFrmSetupAnalysisTypes frmAnalysistypes = new TFrmSetupAnalysisTypes(null);

            frmAnalysistypes.LedgerNumber = FLedgerNumber;
            frmAnalysistypes.Show();
            // Tests schould be repeateable but at the moment we make only a relative test

            // Press the new Button for the types
            String       randomNewValueString = RandomString();
            ButtonTester btnNewType           = new ButtonTester("btnNewType");

            btnNewType.Click();

            TextBoxTester txtDetailAnalysisTypeCode = new TextBoxTester("txtDetailAnalysisTypeCode");

            txtDetailAnalysisTypeCode.Properties.Text = randomNewValueString;
            TextBoxTester txtDetailAnalysisTypeDescription = new TextBoxTester("txtDetailAnalysisTypeDescription");

            txtDetailAnalysisTypeDescription.Properties.Text = "Description for " + randomNewValueString;

            // Press the new Button for the values
            ButtonTester btnNewValue = new ButtonTester("btnNew");

            btnNewValue.Click();

            TextBoxTester txtDetailAnalysisValue = new TextBoxTester("txtDetailAnalysisValue");

            txtDetailAnalysisValue.Properties.Text = randomNewValueString + "-1";
            btnNewValue.Click();

            txtDetailAnalysisValue.Properties.Text = randomNewValueString + "-2";
            CheckBoxTester chkDetailActive = new CheckBoxTester("chkDetailActive");

            Assert.IsTrue(chkDetailActive.Checked, "Active not set as default!");
            chkDetailActive.Properties.Checked = false;


            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");

            // and save everything
            btnSave.Click();
            // Press the delete Button for the values
            ButtonTester btnDeleteValue = new ButtonTester("ucoValues.btnDelete");

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                Assert.AreEqual("Confirm Delete", tester.Title);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteValue.Click();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                Assert.AreEqual("Confirm Delete", tester.Title);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteValue.Click();
            // Press the delete Button for the types
            // TODO: AmbigousNameException. Should we implement this.btnDelete in NUnitForms?
            ButtonTester btnDeleteType = new ButtonTester("btnDelete");

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                Assert.AreEqual("Confirm Delete", tester.Title);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteType.Click();
            btnSave.Click();
        }
Beispiel #22
0
        public void TestImportGLTransactions()
        {
            // create a test batch and journal and then import transactions

            string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/TransactionsImport.csv";

            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            // create a new batch and save
            ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew");

            btnNewBatch.Click();
            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");

            txtDetailBatchDescription.Properties.Text = "Created by test TestImportGLTransactions";

            TabControlTester tabGLBatch = new TabControlTester("tabGLBatch");

            // go to Journal tab
            tabGLBatch.SelectTab(1);

            ButtonTester btnNewJournal = new ButtonTester("ucoJournals.btnAdd");

            btnNewJournal.Click();

            // go to transaction tab
            tabGLBatch.SelectTab(2);

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                OpenFileDialogTester tester = new OpenFileDialogTester(hWnd);

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat          = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "dd/MM/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;

                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    btnOK.Click();
                };

                tester.OpenFile(TestFile);
            };

            ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportTransactions");

            btnImport.Click();

            TSgrdDataGridPagedTester grdDetails = new TSgrdDataGridPagedTester("grdDetails");

            Assert.AreNotEqual(1, grdDetails.Count, "The grid should be populated");
        }
Beispiel #23
0
        public void TestImportExportGLBatch()
        {
            // create two test batches, with some strange figures, to test problem with double values
            // export the 2 test batches, with summarize option
            // compare the exported text file

            string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/GLForm/TestData/BatchImportFloatTest.csv";

            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                OpenFileDialogTester tester = new OpenFileDialogTester(hWnd);

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat          = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "MM/dd/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;

                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    btnOK.Click();
                };

                tester.OpenFile(TestFile);
            };

            ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches");

            btnImport.Click();

            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");

            Assert.IsTrue(btnSave.Properties.Enabled, "Save button has not been activated");
            btnSave.Click();

            // go to Journal tab
            TabControlTester tabGLBatch = new TabControlTester("tabGLBatch");

            tabGLBatch.SelectTab(1);
            TextBoxTester txtBatchNumber = new TextBoxTester("ucoJournals.txtBatchNumber");

            // get the batch number from the journal tab
            int ImportedBatchNumber = Convert.ToInt32(txtBatchNumber.Properties.Text);

            TFrmGLBatchExport frmBatchExport = new TFrmGLBatchExport(null);

            frmBatch.Close();

            // export that batch, summarize the transactions
            // compare the result with the expected file
            frmBatchExport.LedgerNumber = FLedgerNumber;
            frmBatchExport.Show();

            CheckBoxTester chkIncludeUnposted = new CheckBoxTester("chkIncludeUnposted");

            chkIncludeUnposted.Properties.Checked = true;

            RadioButtonTester rbtSummary = new RadioButtonTester("rbtSummary");

            rbtSummary.Properties.Checked = false;

            RadioButtonTester rbtBatchNumberSelection = new RadioButtonTester("rbtBatchNumberSelection");

            rbtBatchNumberSelection.Properties.Checked = true;

            TextBoxTester txtFilename = new TextBoxTester("txtFilename");

            TTxtNumericTextBoxTester txtBatchNumberStart = new TTxtNumericTextBoxTester("txtBatchNumberStart");

            txtBatchNumberStart.Properties.NumberValueInt = ImportedBatchNumber;
            TTxtNumericTextBoxTester txtBatchNumberEnd = new TTxtNumericTextBoxTester("txtBatchNumberEnd");

            txtBatchNumberEnd.Properties.NumberValueInt = ImportedBatchNumber;

            // Test simple export of batches, no summary
            TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTest.csv";
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);
            txtFilename.Properties.Text = TestFile + ".new";

            ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
            {
                MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                // Assert.AreEqual("Success", tester.Title);
                tester2.SendCommand(MessageBoxTester.Command.OK);
            };

            frmBatchExport.ExportBatches(false);

            Assert.AreEqual(true, TTextFile.SameContent(TestFile,
                                                        TestFile + ".new"), "the files should be the same: " + TestFile);
            System.IO.File.Delete(TestFile + ".new");

            // Test export of batches, summarizing the transactions
            TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTestSummary.csv";
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);
            txtFilename.Properties.Text   = TestFile + ".new";
            rbtSummary.Properties.Checked = true;

            ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
            {
                MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                // Assert.AreEqual("Success", tester.Title);
                tester2.SendCommand(MessageBoxTester.Command.OK);
            };

            frmBatchExport.ExportBatches(false);

            Assert.AreEqual(true, TTextFile.SameContent(TestFile,
                                                        TestFile + ".new"), "the files should be the same: " + TestFile);
            System.IO.File.Delete(TestFile + ".new");

            frmBatchExport.Close();
        }
Beispiel #24
0
        private void ClickToolStripButton(string name)
        {
            ToolStripButtonTester tester = new ToolStripButtonTester(name, _window);

            tester.Click();
        }
 public void MainMenuButton()
 {
     ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonOnMain");
     tester.Click();
     Assert.Equal(label1.Text, "toolStripButtonOnMain clicked");
 }
 public void PanelButton()
 {
     ToolStripButtonTester tester = new ToolStripButtonTester("toolStripButtonInPanel");
     tester.Click();
     Assert.Equal(label1.Text, "toolStripButtonInPanel clicked");
 }
Beispiel #27
0
        public void TestCreateBatchAndPost()
        {
            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            // create a new batch and save
            ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew");

            btnNewBatch.Click();
            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");

            txtDetailBatchDescription.Properties.Text = "Created by test TestExportGLBatch";

            TabControlTester tabGLBatch = new TabControlTester("tabGLBatch");

            // go to Journal tab
            tabGLBatch.SelectTab(1);

            ButtonTester btnNewJournal = new ButtonTester("ucoJournals.btnAdd");

            btnNewJournal.Click();

            // go to transaction tab
            tabGLBatch.SelectTab(2);

            ButtonTester btnNewTransaction = new ButtonTester("ucoTransactions.btnNew");

            btnNewTransaction.Click();

            TextBoxTester txtDetailNarrative = new TextBoxTester("txtDetailNarrative");

            txtDetailNarrative.Properties.Text = "test";
            TextBoxTester txtDetailReference = new TextBoxTester("txtDetailReference");

            txtDetailReference.Properties.Text = "test";

            TTxtCurrencyTextBoxTester txtDebitAmount = new TTxtCurrencyTextBoxTester("txtDebitAmount");

            txtDebitAmount.Properties.Focus();
            decimal Amount = 1111.44M;

            txtDebitAmount.Properties.NumberValueDecimal = Amount;

            TCmbAutoPopulatedTester cmbDetailAccountCode = new TCmbAutoPopulatedTester("cmbDetailAccountCode");

            cmbDetailAccountCode.Properties.SetSelectedString("6000");

            TCmbAutoPopulatedTester cmbDetailCostCentreCode = new TCmbAutoPopulatedTester("cmbDetailCostCentreCode");

            cmbDetailCostCentreCode.Properties.SetSelectedString(FLedgerNumber.ToString("00") + "00");

            btnNewTransaction.Click();
            txtDetailNarrative.Properties.Text = "test";
            txtDetailReference.Properties.Text = "test";
            TTxtCurrencyTextBoxTester txtCreditAmount = new TTxtCurrencyTextBoxTester("txtCreditAmount");

            txtDebitAmount.Properties.NumberValueDecimal = 0;
            txtCreditAmount.Properties.Focus();
            txtCreditAmount.Properties.NumberValueDecimal = Amount;

            cmbDetailAccountCode.Properties.Focus();        // This will update the totals
            cmbDetailAccountCode.Properties.SetSelectedString("0200");
            cmbDetailCostCentreCode.Properties.SetSelectedString(FLedgerNumber.ToString("00") + "00");

            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");

            btnSave.Click();

            // go to Batch tab
            tabGLBatch.SelectTab(0);

            // post this batch
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                Assert.IsTrue(tester.Text.StartsWith(
                                  "Are you sure you want to post GL batch"),
                              "Should start with 'are you sure you want to post GL batch', but is '" +
                              tester.Text + "'");

                // there is a second message box after posting, telling the user about success.
                // because the ModalFormHandler is reset after handling the first message box, we need to set up a new handler.
                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                    Assert.AreEqual("Progress Dialog", tester2.Title);

                    //Wait for it to close
                    Thread.Sleep(1000);

                    // there is a second message box after posting, telling the user about success.
                    // because the ModalFormHandler is reset after handling the first message box, we need to set up a new handler.
                    ModalFormHandler = delegate(string name3, IntPtr hWnd3, Form form3)
                    {
                        MessageBoxTester tester3 = new MessageBoxTester(hWnd3);
                        Assert.AreEqual("Success", tester3.Title);

                        tester3.SendCommand(MessageBoxTester.Command.Yes);
                    };
                };

                tester.SendCommand(MessageBoxTester.Command.Yes);
            };

            frmBatch.EnablePostingReport = false;
            ButtonTester btnPost = new ButtonTester("ucoBatches.btnPostBatch");

            btnPost.Click();

            // and now try to create a new batch, bug https://sourceforge.net/apps/mantisbt/openpetraorg/view.php?id=1058
            btnNewBatch.Click();
            btnSave.Click();

            frmBatch.Close();
        }
Beispiel #28
0
        public void SaveAndCancel()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.Show();

            // Save and New buttons
            ToolStripButtonTester btnSave         = new ToolStripButtonTester("tbbSave", mainScreen);
            ButtonTester          btnNew          = new ButtonTester("btnNew", mainScreen);
            TTxtNumericTextBox    txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            // Add new row, save and close
            btnNew.Click();
            txtExchangeRate.NumberValueDecimal = 10m;

            btnSave.Click();
            mainScreen.Close();

            // Create the screen a second time
            TFrmSetupCorporateExchangeRate mainScreen2 = new TFrmSetupCorporateExchangeRate(null);

            mainScreen2.Show();

            // make sure the data really got saved
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen2).Properties);

            Assert.AreEqual(3, grdDetails.Rows.Count);

            btnNew          = new ButtonTester("btnNew", mainScreen2);
            txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen2)).Properties;

            // Add another row, but this time close without saving
            btnNew.Click();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.No);
            };

            mainScreen2.Close();

            // Create the screen a third time
            TFrmSetupCorporateExchangeRate mainScreen3 = new TFrmSetupCorporateExchangeRate(null);

            mainScreen3.Show();

            // make sure the data did not get saved
            grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen3).Properties);
            Assert.AreEqual(3, grdDetails.Rows.Count);

            btnNew          = new ButtonTester("btnNew", mainScreen3);
            txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen3)).Properties;

            // Add another row, but this time close AND save
            btnNew.Click();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };

            mainScreen3.Close();

            // Create the screen a fourth time!
            TFrmSetupCorporateExchangeRate mainScreen4 = new TFrmSetupCorporateExchangeRate(null);

            mainScreen4.Show();

            // make sure the data was saved last time
            grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen4).Properties);
            Assert.AreEqual(5, grdDetails.Rows.Count);

            mainScreen4.Close();
        }