Esempio n. 1
0
        public void UnexpectedModal(IntPtr hWnd)
        {
            MessageBoxTester messageBox = new MessageBoxTester(hWnd);

            //wesay
            //jdh
            //original: messageBox.ClickOk();
            //new
            throw new ApplicationException("Unexpected messagebox: " + messageBox.Text);
        }
Esempio n. 2
0
        private void バリデーションメッセージ確認(string text, string message)
        {
            var target = new FizzBuzzForm();
            target.Show();

            DialogBoxHandler = (title, handle) =>
            {
                var messageBox = new MessageBoxTester(handle);
                Assert.That(messageBox.Text, Is.EqualTo(message));
                messageBox.ClickOk();
            };

            new TextBoxTester("maxNumberTextBox", target).Enter(text);
            new ButtonTester("fizzBuzzButton", target).Click();
        }
        /// <summary>
        /// The delegate to handle the message box is installed.
        /// </summary>
        /// <param name="cmd">Contains a NUnit.Extensions.Forms.MessageBoxTester.Command to
        /// insert the desired reaction.</param>
        public void WaitForMessageBox(NUnit.Extensions.Forms.MessageBoxTester.Command cmd)
        {
            lastMessageTitle = "";
            lastMessageText = "";

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

                System.Console.WriteLine("Title: " + tester.Title);
                System.Console.WriteLine("Message: " + tester.Text);

                lastMessageTitle = tester.Title;
                lastMessageText = tester.Text;

                tester.SendCommand(cmd);
            };
        }
Esempio n. 4
0
 private void OnCloseMessageBox()
 {
     var mbt = new MessageBoxTester("Test");
     mbt.ClickOk();
 }
Esempio n. 5
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");
        }
Esempio n. 6
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("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
            ButtonTester btnDeleteType = new ButtonTester("btnDeleteType");
            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();
        }
Esempio n. 7
0
        /// <summary>
        /// Handler for LoadModalTableWithData test
        /// </summary>
        public void LoadModalTableHandler()
        {
            FormTester formTester = new FormTester(FModalFormName);
            TFrmSetupDailyExchangeRate mainScreen = (TFrmSetupDailyExchangeRate)formTester.Properties;

            // Controls
            ButtonTester btnCloseTester = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            Button btnClose = btnCloseTester.Properties;
            Button btnDelete = (new ButtonTester("btnDelete", FModalFormName)).Properties;
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)((new TSgrdDataGridPagedTester("grdDetails", FModalFormName)).Properties);
            Panel pnlDetails = (new PanelTester("pnlDetails", FModalFormName)).Properties;
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", FModalFormName)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", FModalFormName)).Properties;
            TtxtPetraDate dtpDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            // These should be the states given the standard modal data we loaded
            try
            {
                mainScreen.TFrmSetupDailyExchangerate_Shown(null, null);
                Assert.AreEqual("EUR", cmbFromCurrency.GetSelectedString());                    // GBP passed in as a ShowDialog parameter
                Assert.AreEqual(STANDARD_TEST_CURRENCY, cmbToCurrency.GetSelectedString());     // The ledger currency for the ledger passed in as parameter
                Assert.AreEqual(FStandardEffectiveDate, dtpDateEffective.Date);
                Assert.AreEqual(0.0m, txtRateOfExchange.NumberValueDecimal);
                Assert.IsFalse(cmbFromCurrency.Enabled);
                Assert.IsFalse(cmbToCurrency.Enabled);
                Assert.IsFalse(btnClose.Enabled);                           // button will be disabled because rate is 0.00
                Assert.IsTrue(btnClose.Visible);
                Assert.IsTrue(btnCancelTester.Properties.Visible);
                Assert.IsTrue(btnDelete.Enabled);
                Assert.IsTrue(pnlDetails.Enabled);
                Assert.AreEqual(4, grdDetails.Rows.Count);      // added a new row
                txtRateOfExchange.NumberValueDecimal = 0.5333m;

                // Save this as our rate and quit
                string dlgText = String.Empty;
                bool dlgDisplayed = false;

                // Set up a popup handler
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    dlgText = tester.Text;
                    dlgDisplayed = true;
                    tester.SendCommand(MessageBoxTester.Command.Yes);
                };

                btnCloseTester.Click();
                Assert.IsTrue(dlgDisplayed, "Expected a validation dialog");
                Assert.IsTrue(dlgText.Contains("earliest current accounting period"), "Expected a warning about dates");
            }
            catch (Exception ex)
            {
                // Handle the exception and abort without saving
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Esempio n. 8
0
        public void Validation()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);
            mainScreen.Show();

            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            btnNew.Click();

            // Set up some bad entries
            dtpEffectiveDate.Text = "";
            txtExchangeRate.NumberValueDecimal = 0.0m;

            string dlgText = String.Empty;
            bool dlgDisplayed = false;

            // Click the New button and discover what validation errors we have
            // Note - we do not put assert's inside the delegate because we want the dialog to close.
            //   If the dialog is left hanging this might do bad stuff to automated testing
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                dlgText = tester.Text;
                dlgDisplayed = true;
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            btnNew.Click();

            // Check that we did display the dialog and that we picked up the validation errors we predicted
            Assert.IsTrue(dlgDisplayed);
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_NOUNDEFINEDDATE));
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_INVALIDNUMBER));

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

            mainScreen.Close();
        }
Esempio n. 9
0
        public void InvertRate()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel pnlDetails = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;
            ButtonTester btnInvert = new ButtonTester("btnInvertExchangeRate", mainScreen);

            // Select the first row in the grid.  New rows should be based on data row 5
            SelectRowInGrid(1, 5);

            // Check that Invert enabled and test that it works
            btnNew.Click();
            Assert.IsTrue(btnInvert.Properties.Enabled);
            txtExchangeRate.NumberValueDecimal = 5.0m;
            btnInvert.Click();
            Assert.AreEqual(0.2m, txtExchangeRate.NumberValueDecimal);
            btnInvert.Click();
            Assert.AreEqual(5.0m, txtExchangeRate.NumberValueDecimal);

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

            mainScreen.SaveChanges();
            mainScreen.Close();
        }
Esempio n. 10
0
        /// <summary>
        /// Handler for the UnusedExchangeRateUsageHandler test
        /// </summary>
        public void UnusedExchangeRateUsageHandler()
        {
            FormTester formTester = new FormTester(FModalFormName);
            TFrmSetupDailyExchangeRate mainScreen = (TFrmSetupDailyExchangeRate)formTester.Properties;

            // Controls
            ButtonTester btnCloseTester = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            TtxtPetraDate dtpDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;
            TextBox txtTimeEffective = (new TextBoxTester("txtDetailTimeEffectiveFrom", FModalFormName)).Properties;

            mainScreen.TFrmSetupDailyExchangerate_Shown(null, null);

            try
            {
                Assert.AreEqual(3, mainScreen.MainGridRowCount, "Wrong number of rows in the grid");
                txtRateOfExchange.NumberValueDecimal = 0.4999m;

                // Set up a popup handler
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    tester.SendCommand(MessageBoxTester.Command.OK);
                };

                for (int i = 3; i > 0; i--)
                {
                    SelectRowInGrid(i);

                    string Usage = ((TFrmSetupDailyExchangeRate)formTester.Properties).Usage;
                    Assert.AreEqual("0 Journals and 0 Gift Batches;", Usage, "Unexpected row in the grid!");

                    Console.WriteLine("Grid row {0}: rate: {1}: date: {2} time:{3}",
                        i,
                        txtRateOfExchange.NumberValueDecimal.Value.ToString(),
                        dtpDateEffective.Date.Value.ToString("yyyy-MM-dd"),
                        txtTimeEffective.Text);

                    switch (i)
                    {
                        case 1:
                            Assert.AreEqual(0.4999m, txtRateOfExchange.NumberValueDecimal.Value, "Wrong rate of exchange in row " + i.ToString());
                            break;

                        case 2:
                            Assert.AreEqual(0.51m, txtRateOfExchange.NumberValueDecimal.Value, "Wrong rate of exchange in row " + i.ToString());
                            Assert.AreEqual("1900-07-01", dtpDateEffective.Date.Value.ToString("yyyy-MM-dd"), "Wrong date in row " + i.ToString());
                            Assert.AreEqual("02:00", txtTimeEffective.Text, "Wrong time in row " + i.ToString());
                            break;

                        case 3:
                            Assert.AreEqual(0.50m, txtRateOfExchange.NumberValueDecimal.Value, "Wrong rate of exchange in row " + i.ToString());
                            Assert.AreEqual("1900-06-01", dtpDateEffective.Date.Value.ToString("yyyy-MM-dd"), "Wrong date in row " + i.ToString());
                            Assert.AreEqual("02:00", txtTimeEffective.Text, "Wrong time in row " + i.ToString());
                            break;

                        default:
                            break;
                    }
                }

                // Save this as our rate and quit
                string dlgText = String.Empty;
                bool dlgDisplayed = false;

                // Set up a popup handler
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    dlgText = tester.Text;
                    dlgDisplayed = true;
                    tester.SendCommand(MessageBoxTester.Command.Yes);
                };

                btnCloseTester.Click();
                Assert.IsTrue(dlgDisplayed, "Expected a validation dialog");
                Assert.IsTrue(dlgText.Contains("earliest current accounting period"), "Expected a warning about dates");
            }
            catch (Exception ex)
            {
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Esempio n. 11
0
 private void OnModal_DismissMessageBox()
 {
     var mbt = new MessageBoxTester(ErrorDialogCaption);
        mbt.ClickOk();
 }
Esempio n. 12
0
        public void Validation()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);
            mainScreen.Show();
            mainScreen.ShowUnusedRates();

            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;
            TextBox txtTimeEffective = (new TextBoxTester("txtDetailTimeEffectiveFrom", mainScreen)).Properties;

            btnNew.Click();

            string dlgText = String.Empty;
            bool dlgDisplayed = false;

            // Set up some bad entries
            // We already have an invalid rate (it will be 0.0)

            // Click the New button and discover what validation errors we have
            // Note - we do not put assert's inside the delegate because we want the dialog to close.
            //   If the dialog is left hanging this might do bad stuff to automated testing
            // Also note that dialogs with long text content get their text clipped in Tester.Text.
            // For that reason we are going to have to run three tests here instead of just one to do them all
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                dlgText = tester.Text;
                dlgDisplayed = true;
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            btnNew.Click();

            // Check that we did display the dialog and that we picked up the validation errors we predicted
            Assert.IsTrue(dlgDisplayed);
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_INVALIDNUMBER), dlgText);

            // Set up second bad entry
            txtExchangeRate.NumberValueDecimal = 2.0m;
            string prevDateText = dtpEffectiveDate.Text;
            dtpEffectiveDate.Text = "";
            dlgDisplayed = false;
            dlgText = String.Empty;

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                dlgText = tester.Text;
                dlgDisplayed = true;
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            btnNew.Click();

            Assert.IsTrue(dlgDisplayed);
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_NOUNDEFINEDDATE), dlgText);

            // Set up third bad entry
            dtpEffectiveDate.Text = prevDateText;
            txtTimeEffective.Text = "09:80";
            dlgDisplayed = false;
            dlgText = String.Empty;

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                dlgText = tester.Text;
                dlgDisplayed = true;
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            btnNew.Click();

            Assert.IsTrue(dlgDisplayed);
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_INVALIDINTEGERTIME), dlgText);

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

            mainScreen.Close();
        }
Esempio n. 13
0
        public void DeleteRows()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);
            mainScreen.Show();
            mainScreen.ShowUnusedRates();

            // Toolstrip
            ToolStripButtonTester btnSaveTester = new ToolStripButtonTester("tbbSave", mainScreen);
            ButtonWithFocusTester btnNewTester = new ButtonWithFocusTester("btnNew", mainScreen);
            ButtonWithFocusTester btnDeleteTester = new ButtonWithFocusTester("btnDelete", mainScreen);
            //ButtonWithFocusTester btnEnableEdit = new ButtonWithFocusTester("btnEnableEdit", mainScreen);
            TSgrdDataGridPagedTester grdTester = new TSgrdDataGridPagedTester("grdDetails", mainScreen);
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)grdTester.Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;
            TtxtPetraDate txtDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;

            // All rows in grid should be deletable because they are unused
            Assert.AreEqual(9, grdDetails.Rows.Count);
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);

            // Create 3 new rows
            btnNewTester.Click();
            btnNewTester.Click();
            btnNewTester.Click();

            Assert.AreEqual(12, grdDetails.Rows.Count);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // New rows should be deletable
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();

            Assert.IsFalse(cmbFromCurrency.Enabled);
            Assert.IsFalse(cmbToCurrency.Enabled);
            Assert.IsFalse(txtDateEffective.Enabled);
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);

            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Now we should be back to being able to delete a unused row
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            Assert.AreEqual(9, grdDetails.Rows.Count);
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);

            // Activate deletion of saved rows
            //btnEnableEdit.Click();
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);

            // Now we should be able to delete the row we could not delete before
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);

            // Change to the first row
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);
            SelectRowInGrid(1);
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());

            // So now we should have our 2 rows far in the future at the top which are not used anywhere
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();
            Assert.IsTrue(txtDateEffective.Date.Value.Year < 1910 || txtDateEffective.Date.Value.Year > 2980);

            // Should still be on row 1 with 7 grid rows now that 2 have gone
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            Assert.AreEqual(7, grdDetails.Rows.Count);

            // Delete rows starting at the bottom
            SelectRowInGrid(6);
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnDeleteTester.Click();

            Assert.AreEqual(4, mainScreen.GetSelectedRowIndex());
            Assert.IsTrue(btnDeleteTester.Properties.Enabled);
            Assert.AreEqual(5, grdDetails.Rows.Count);

            // Save the new settings - deleting does not remove inverse rows when saved
            Assert.IsTrue(btnSaveTester.Properties.Enabled);
            btnSaveTester.Click();
            Assert.IsFalse(btnSaveTester.Properties.Enabled);
            Assert.AreEqual(5, grdDetails.Rows.Count);
        }
Esempio n. 14
0
		public void UnexpectedModal(IntPtr hWnd)
		{
			MessageBoxTester messageBox = new MessageBoxTester(hWnd);
			//wesay
			//jdh
			//original: messageBox.ClickOk();
			//new
			throw new ApplicationException("Unexpected messagebox: " + messageBox.Text);
		}
Esempio n. 15
0
        public void AddRowToTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel pnlDetails = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;
            TextBox txtTimeEffective = (new TextBoxTester("txtDetailTimeEffectiveFrom", mainScreen)).Properties;

            // Select the bottom row - when we get a new row it should be based on StandardData[1]
            SelectRowInGrid(FAllRowCount, 1);

            // Check that the controls are disabled.  But the exchange rate itself can be edited because the rows are unused.
            Assert.IsFalse(cmbFromCurrency.Enabled);
            Assert.IsFalse(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.ReadOnly);
            Assert.IsTrue(txtExchangeRate.Enabled);
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");

            // Click the 'New' button
            btnNew.Click();
            Assert.IsTrue(btnSave.Enabled, "The Save button should be enabled after adding a new row");
            Assert.IsTrue(cmbFromCurrency.Enabled);
            Assert.IsTrue(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.Enabled);
            Assert.IsTrue(txtExchangeRate.Enabled);

            // The effective date should be 1st of current month
            DateTime expectedDate = DateTime.Today;

            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal.Value);

            // The row number of the new row should be at row 7
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

            // Change the rate to a new value - more than 10% different
            decimal newRate = 0.667m;
            txtExchangeRate.NumberValueDecimal = newRate;

            // click the 'New' button again - this time the date should be the same but the time should be 7800
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            btnNew.Click();

            string expectedTime = "02:10";

            // The details should be the same as before except for the new date and the rate being what we just set
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(expectedTime, txtTimeEffective.Text);
            Assert.AreEqual(newRate, txtExchangeRate.NumberValueDecimal.Value);
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

            // Save the changes and check the number of rows now (we will get our rate alert warning dialog again)
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.Yes);
            };
            // We have added 2 new rows but the same rate at different times of day
            // When we save the duplicate row will get removed, so we will end up with 10 data rows
            mainScreen.SaveChanges();
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled after the new row has been saved");
            Assert.AreEqual(11, grdDetails.Rows.Count, "There should be 10 rows in the grid after saving 2 new rows (but duplicates of each other)");

            mainScreen.Close();
        }
Esempio n. 16
0
        private void HandleMessageBox(string name, IntPtr hWnd)
        {
            NumberOfMessageBoxes++;

            MessageBoxTester tester = new MessageBoxTester(hWnd);

            TLogging.Log("HandleMessageBox: " + NumberOfMessageBoxes.ToString() + ": " +
                tester.Text.Replace(Environment.NewLine, " "));

            DialogBoxHandler = HandleMessageBox;

            tester.SendCommand(MessageBoxTester.Command.OK);
        }
Esempio n. 17
0
        /// <summary>
        /// Handler for the GiftBatchUsage test
        /// </summary>
        public void ModalValidationHandler()
        {
            // Controls
            ButtonTester btnNewTester = new ButtonTester("btnNew", FModalFormName);
            ButtonTester btnCloseTester = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            TtxtPetraDate dtpDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            try
            {
                // Create a new row and set the rate
                btnNewTester.Click();
                txtRateOfExchange.NumberValueDecimal = 2.0m;
                string dlgText = String.Empty;
                bool dlgDisplayed = false;

                // Set up a popup handler
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    dlgText = tester.Text;
                    dlgDisplayed = true;
                    tester.SendCommand(MessageBoxTester.Command.OK);
                };

                // Try setting the date to the day after the end and then clicking New
                dtpDateEffective.Date = FStandardEffectiveDate.AddDays(1.0);
                btnNewTester.Click();
                Assert.IsTrue(dlgDisplayed, "The date chosen for the test should have raised a validation errror");
                Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_DATENOTINDATERANGE));

                // Set up another popup handler
                dlgText = String.Empty;
                dlgDisplayed = false;
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    dlgText = tester.Text;
                    dlgDisplayed = true;
                    tester.SendCommand(MessageBoxTester.Command.OK);
                };

                // Try setting the date to the day before the start and then clicking New
                dtpDateEffective.Date = FStandardEffectiveDate.AddDays(-11.0);
                btnNewTester.Click();
                Assert.IsTrue(dlgDisplayed, "The date chosen for the test should have raised a validation errror");
                Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_DATENOTINDATERANGE));

                // Set the date to a valid date and close (and save)
                dtpDateEffective.Date = FStandardEffectiveDate;
                btnCloseTester.Click();
            }
            catch (Exception ex)
            {
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Esempio n. 18
0
        public void AddRowToTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel pnlDetails = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            // Select the bottom row - when we get a new row it should be based on StandardData[1]
            SelectRowInGrid(FAllRowCount, 1);

            // Check that the controls are disabled
            Assert.IsFalse(cmbFromCurrency.Enabled);
            Assert.IsFalse(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.ReadOnly);

            // Check that the controls are enabled
            Assert.IsTrue(txtExchangeRate.Enabled);

            // Click the 'New' button
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            btnNew.Click();
            Assert.IsTrue(btnSave.Enabled, "The Save button should be enabled after adding a new row");
            Assert.IsTrue(cmbFromCurrency.Enabled);
            Assert.IsTrue(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.Enabled);
            Assert.IsTrue(txtExchangeRate.Enabled);

            // The effective date should be 1st of current month
            DateTime expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal.Value);

            // The row number of the new row should be at row 7
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

            // Change the rate to a new value
            decimal newRate = 0.667m;
            txtExchangeRate.NumberValueDecimal = newRate;

            // click the 'New' button again - this time the date should be first of next month
            btnNew.Click();
            expectedDate = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(1);

            // The details should be the same as before except for the new date and the rate being what we just set
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(newRate, txtExchangeRate.NumberValueDecimal.Value);
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

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

            // Save the changes and check the number of rows now
            mainScreen.SaveChanges();
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled after the new row has been saved");
            Assert.AreEqual(13, grdDetails.Rows.Count, "There should be 12 rows in the grid after saving 2 new rows");

            mainScreen.Close();
        }
Esempio n. 19
0
        /// <summary>
        /// A <see cref="ModalFormActivatedHwnd"/> that tries to click the OK button of the modal form.
        ///</summary>
        public void UnexpectedModal(IntPtr hWnd)
        {
            MessageBoxTester messageBox = new MessageBoxTester(hWnd);

            messageBox.ClickOk();
        }
Esempio n. 20
0
        /// <summary>
        /// Handler for the UsedExchangeRateUsage test
        /// </summary>
        public void UsedExchangeRateUsageHandler()
        {
            FormTester formTester = new FormTester(FModalFormName);
            TFrmSetupDailyExchangeRate mainScreen = (TFrmSetupDailyExchangeRate)formTester.Properties;

            // Controls
            ButtonTester btnCloseTester = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            TtxtPetraDate dtpDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            // This will create a new unused rate
            mainScreen.TFrmSetupDailyExchangerate_Shown(null, null);
            txtRateOfExchange.NumberValueDecimal = 0.525m;
            // This will hide it and apply the new filter
            mainScreen.ShowUsedRatesAtStartUp = true;

            // Set up a popup handler
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            try
            {
                Assert.AreEqual(13, mainScreen.MainGridRowCount, "Wrong number of rows in the grid");

                for (int i = 13; i > 0; i--)
                {
                    SelectRowInGrid(i);
                    string Usage = mainScreen.Usage;
                    Console.WriteLine("Grid row {0}: rate: {1}: {2}", i, txtRateOfExchange.NumberValueDecimal.Value.ToString(), Usage);
                    // Usage is of form "Ledger:{0} Batch:{1} Journal:{2} Status:{3} at Rate:{4} on Date:{5} at Time:{6}"

                    Assert.IsTrue(Usage.Contains("Ledger:9997"), "Expected a reference to Ledger #9997, but was: " + Usage);

                    switch (i)
                    {
                        case 1:             // 0.5275
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected an unposted row in GL Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:115"), "Expected a reference to Batch 115, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:2"), "Expected a reference to Journal 2, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5275"), "Expected a reference to a rate of 0.5275, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-30"), "Expected a reference to a date of 2000-10-30, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:60"), "Expected a reference to Time 60, but was: " + Usage);
                            break;

                        case 2:             // 0.5245
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected an unposted row in GL Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:115"), "Expected a reference to Batch 115, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5245"), "Expected a reference to a rate of 0.5245, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-30"), "Expected a reference to a date of 2000-10-30, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 3:             // 0.5225
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected two unposted rows in Journal table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:114 Journal:1 "), "Expected a reference to Batch 114 Journal 1, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:114 Journal:2 "), "Expected a reference to Batch 114 Journal 2, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5225"), "Expected a reference to a rate of 0.5225, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-28"), "Expected a reference to a date of 2000-10-28, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:14400"), "Expected a reference to Time 14400, but was: " + Usage);
                            break;

                        case 4:             // 0.5225
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected two unposted rows in Journal table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:113 Journal:1 "), "Expected a reference to Batch 113 Journal 1, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:113 Journal:2 "), "Expected a reference to Batch 113 Journal 2, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5225"), "Expected a reference to a rate of 0.5225, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-27"), "Expected a reference to a date of 2000-10-27, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 5:             // 0.5225
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected an unposted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:112"), "Expected a reference to Batch 112, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5225"), "Expected a reference to a rate of 0.5225, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-26"), "Expected a reference to a date of 2000-10-26, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 6:             // 0.5225
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected an unposted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:111"), "Expected a reference to Batch 111, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5225"), "Expected a reference to a rate of 0.5225, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-22"), "Expected a reference to a date of 2000-10-22, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 7:             // 0.5225
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted "), "Expected an unposted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:22"), "Expected a reference to Batch 22, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5225"), "Expected a reference to a rate of 0.5225, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-05"), "Expected a reference to a date of 2000-10-05, but was: " + Usage);
                            // NB: The time for a gift batch usage is always 0 - even though on screen the usage for this is 02:00 (from DER table)
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 8:             // 0.5155
                            Assert.IsTrue(Usage.Contains(
                                "Status:Unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:21"), "Expected a reference to Batch 21, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5155"), "Expected a reference to a rate of 0.5155, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-10-01"), "Expected a reference to a date of 2000-10-01, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 9:             // 0.5195
                            Assert.IsTrue(Usage.Contains(
                                "Status:Posted"), "Expected a posted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:20"), "Expected a reference to Batch 20, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5195"), "Expected a reference to a rate of 0.5195, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-08-30"), "Expected a reference to a date of 2000-08-30, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:60"), "Expected a reference to Time 60, but was: " + Usage);
                            break;

                        case 10:             // 0.5185
                            Assert.IsTrue(Usage.Contains(
                                "Status:Posted"), "Expected a posted row in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Batch:19"), "Expected a reference to Batch 19, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5185"), "Expected a reference to a rate of 0.5185, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-08-30"), "Expected a reference to a date of 2000-08-30, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 11:             // 0.5155
                            Assert.IsTrue(Usage.Contains(
                                "Batch:103 Journal:1 Status:Unposted"),
                            "Expected an unposted row for batch 103/Journal 1 in Journal table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:17 Journal:0 Status:Posted"), "Expected a posted row for batch 17 in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:18 Journal:0 Status:Posted"), "Expected a posted row for batch 18 in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5155"), "Expected a reference to a rate of 0.5155, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-08-28"), "Expected a reference to a date of 2000-08-28, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 12:             // 0.5155
                            Assert.IsTrue(Usage.Contains(
                                "Batch:102 Journal:1 Status:Unposted"),
                            "Expected an unposted row for batch 102/Journal 1 in Journal table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:16 Journal:0 Status:Posted"), "Expected a posted row for batch 16 in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5155"), "Expected a reference to a rate of 0.5155, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-08-08"), "Expected a reference to a date of 2000-08-08, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        case 13:             // 0.5155
                            Assert.IsTrue(Usage.Contains(
                                "Batch:101 Journal:1 Status:Unposted"),
                            "Expected an unposted row for batch 101/Journal 1 in Journal table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains(
                                "Batch:15 Journal:0 Status:Posted"), "Expected a posted row for batch 15 in Gift Batch table, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Rate:0.5155"), "Expected a reference to a rate of 0.5155, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Date:2000-08-01"), "Expected a reference to a date of 2000-08-01, but was: " + Usage);
                            Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage);
                            break;

                        default:
                            break;
                    }
                }

                btnCloseTester.Click();
            }
            catch (Exception ex)
            {
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Esempio n. 21
0
        public void AddRowToEmptyTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);
            mainScreen.RunOnceOnActivation();
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel pnlDetails = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            btnNew.Click();
            Assert.IsTrue(btnSave.Enabled, "The Save button should be enabled after adding a new row");

            // Work out our expectations
            string expectedToCurrency = "USD";
            string baseCurrency = GetDefaultBaseCurrency();

            if (baseCurrency == "USD")
            {
                baseCurrency = "GBP";
            }

            DateTime expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            // Check the details panel after adding the new row
            Assert.AreEqual(baseCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(expectedToCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);

            // Set a valid exchange rate and save
            txtExchangeRate.NumberValueDecimal = 2.0m;

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

            mainScreen.SaveChanges();
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled after the new row has been saved");

            // Check the row count in the grid
            Assert.AreEqual(3, grdDetails.Rows.Count, "There should be 2 rows in the grid after saving a new row");

            // Even though an inverse row has been added we should still be highlighting the newly added row
            Assert.AreEqual(baseCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(expectedToCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(2.0m, txtExchangeRate.NumberValueDecimal);

            // Now select the inverese row
            SelectRowInGrid(1);

            // Check the details are, in fact, the inverse
            Assert.AreEqual(expectedToCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(baseCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(0.5m, txtExchangeRate.NumberValueDecimal);

            mainScreen.Close();
        }
        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");
        }
Esempio n. 23
0
        public void EditRow()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel pnlDetails = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester btnNew = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            // Select the first row in the grid.  New rows should be based on data row 5
            SelectRowInGrid(1, 5);

            // Add three rows
            btnNew.Click();
            btnNew.Click();
            btnNew.Click();

            DateTime dt1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            //DateTime dt2 = dt1.AddMonths(1);
            DateTime dt3 = dt1.AddMonths(2);

            // Check the data first
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(dt3, dtpEffectiveDate.Date);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal.Value);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Focus on the from currency, then change it to 'BEF'
            cmbFromCurrency.Focus();
            cmbFromCurrency.SetSelectedString("BEF");
            cmbToCurrency.Focus();

            // Now check the date and rate.  Date should be back to this month and rate should be 0.00 because this currency has never been used
            Assert.AreEqual(dt1, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());

            // Reset the currency and confirm we go back to where we were
            cmbFromCurrency.Focus();
            cmbFromCurrency.SetSelectedString(EffectiveCurrency(FFromCurrencyId));
            cmbToCurrency.Focus();

            Assert.AreEqual(dt3, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Repeat for the To currency
            cmbToCurrency.Focus();
            cmbToCurrency.SetSelectedString("BEF");
            dtpEffectiveDate.Focus();

            // Now check the date and rate.  Date should be back to this month and rate should be 0.00 because this currency has never been used
            Assert.AreEqual(dt1, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());

            // Reset the currency and confirm we go back to where we were
            cmbToCurrency.Focus();
            cmbToCurrency.SetSelectedString(EffectiveCurrency(FToCurrencyId));
            dtpEffectiveDate.Focus();

            Assert.AreEqual(dt3, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Finally check what happens when editing the date
            SelectRowInGrid(5);
            txtExchangeRate.NumberValueDecimal = 8.0m;      // Today
            FixUnvalidatedChanges();
            SelectRowInGrid(4);
            txtExchangeRate.NumberValueDecimal = 9.0m;      // Today + 1m
            FixUnvalidatedChanges();
            SelectRowInGrid(3);
            txtExchangeRate.NumberValueDecimal = 10.0m;     // Today +2m
            FixUnvalidatedChanges();

            SelectRowInGrid(5);
            Assert.AreEqual(8.0m, txtExchangeRate.NumberValueDecimal);
            dtpEffectiveDate.Focus();
            dtpEffectiveDate.Date = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(6);
            grdDetails.Focus();
            Assert.AreEqual(10.0m, txtExchangeRate.NumberValueDecimal);

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

            mainScreen.SaveChanges();
            mainScreen.Close();
        }
Esempio n. 24
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") + "/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");

            ToolStripButtonTester tbbExportBatches = new ToolStripButtonTester("tbbExportBatches");

            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);
            };

            tbbExportBatches.Click();

            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);
            };

            tbbExportBatches.Click();

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

            frmBatchExport.Close();
        }
Esempio n. 25
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();
        }
Esempio n. 26
0
        public void TestViewPostedBatchTransactionsAndAddBatch()
        {
            //This test adds a new batch, saves and posts it, then views it and then tries to add a new batch

            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");
            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.SetSelectedString("0200");
            cmbDetailCostCentreCode.Properties.SetSelectedString(FLedgerNumber.ToString("00") + "00");

            //ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");
            //btnSave.Click();

            // 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 batch"),
                    "Should start with 'are you sure you want to post 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("Success", tester2.Title);
                    tester2.SendCommand(MessageBoxTester.Command.Yes);
                };

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

            // and now try to create a new batch, bug https://sourceforge.net/apps/mantisbt/openpetraorg/view.php?id=1058
            // go to Batch tab
            tabGLBatch.SelectTab(0);

            ButtonTester btnPostBatch = new ButtonTester("ucoBatches.btnPostBatch");
            btnPostBatch.Click();

            //Make sure the grid is clear
            RadioButtonTester rbtPosting = new RadioButtonTester("rbtPosting");
            rbtPosting.Properties.Checked = true;

            //This will then select the first batch in the grid which needs to be posted
            RadioButtonTester rbtAll = new RadioButtonTester("rbtAll");
            rbtAll.Properties.Checked = true;

            //TabControlTester tabGLBatch = new TabControlTester("tabGLBatch");

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

            // go to Transaction Tab
            tabGLBatch.SelectTab(2);

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

            //ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew");
            btnNewBatch.Click();
        }
Esempio n. 27
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();
        }
Esempio n. 28
0
        /// <summary>
        /// Handler for ModalEmptyTable test
        /// </summary>
        public void LoadModalEmptyTableHandler()
        {
            FormTester formTester = new FormTester(FModalFormName);
            TFrmSetupDailyExchangeRate mainScreen = (TFrmSetupDailyExchangeRate)formTester.Properties;

            // Controls
            ButtonTester btnNewTester = new ButtonTester("btnNew", FModalFormName);
            ButtonTester btnCloseTester = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            Button btnNew = btnNewTester.Properties;
            Button btnClose = btnCloseTester.Properties;
            Button btnDelete = (new ButtonTester("btnDelete", FModalFormName)).Properties;
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)((new TSgrdDataGridPagedTester("grdDetails", FModalFormName)).Properties);
            Panel pnlDetails = (new PanelTester("pnlDetails", FModalFormName)).Properties;
            TCmbAutoPopulated cmbFromCurrency = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", FModalFormName)).Properties;
            TCmbAutoPopulated cmbToCurrency = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", FModalFormName)).Properties;
            TtxtPetraDate dtpDateEffective = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            // These should be the states on an empty modal screen (as loaded)
            try
            {
                // A new row will automatically have been added since we are modal

                // These should be the states after adding a new row
                mainScreen.TFrmSetupDailyExchangerate_Shown(null, null);
                Assert.AreEqual("EUR", cmbFromCurrency.GetSelectedString());
                Assert.AreEqual(STANDARD_TEST_CURRENCY, cmbToCurrency.GetSelectedString());
                Assert.AreEqual(FStandardEffectiveDate, dtpDateEffective.Date);
                Assert.IsFalse(cmbFromCurrency.Enabled);
                Assert.IsFalse(cmbToCurrency.Enabled);
                Assert.IsTrue(btnClose.Enabled);
                Assert.IsTrue(btnDelete.Enabled);
                Assert.IsTrue(pnlDetails.Enabled);
                Assert.AreEqual(2, grdDetails.Rows.Count);

                // Rate should be 0.0m - we will need to set it to something else
                Assert.AreEqual(1.111m, txtRateOfExchange.NumberValueDecimal);
                txtRateOfExchange.NumberValueDecimal = STANDARD_RATE_OF_EXCHANGE;

                // Save this as our rate and quit
                string dlgText = String.Empty;
                bool dlgDisplayed = false;

                // Set up a popup handler
                ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
                {
                    MessageBoxTester tester = new MessageBoxTester(hWnd);
                    dlgText = tester.Text;
                    dlgDisplayed = true;
                    tester.SendCommand(MessageBoxTester.Command.Yes);
                };

                btnCloseTester.Click();
                Assert.IsTrue(dlgDisplayed, "Expected a validation dialog");
                Assert.IsTrue(dlgText.Contains("earliest current accounting period"), "Expected a warning about dates");
            }
            catch (Exception ex)
            {
                // Handle the exception and abort without saving
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }