public void ButtonForm2Click() { LaunchForm1(); var Form1BtnTester = new ButtonTester("Form2Btn", testForm); ExpectModal("testForm2", "OnCloseTestForm2"); Form1BtnTester.Click(); }
public void SelectingThemePageLoadsSettings() { ListViewTester listViewTester = new ListViewTester("PageListView", _optionsForm); listViewTester.Select("Theme"); ButtonTester buttonTester = new ButtonTester("btnThemeNew", _optionsForm); Assert.That(buttonTester.Text, Does.Match("New")); }
public void noSuchButtonStringTest() { form = new MessageDialog(); form.Show(); ButtonTester b = new ButtonTester("openBtn"); b.Click(); }
public void ButtonMessageBoxClick() { LaunchForm1(); var msgBtnTester = new ButtonTester("MessageBtn", testForm); ExpectModal("Test", "OnCloseMessageBox"); msgBtnTester.Click(); }
public void ClickingCancelClosesPasswordForm() { bool eventFired = false; _passwordForm.FormClosed += (o, e) => eventFired = true; ButtonTester cancelButton = new ButtonTester("btnCancel", _passwordForm); cancelButton.Click(); Assert.That(eventFired, Is.True); }
public void ClickingOKButtonClosesTheForm() { bool eventFired = false; _optionsForm.FormClosed += (o, e) => eventFired = true; ButtonTester cancelButton = new ButtonTester("OkButton", _optionsForm); cancelButton.Click(); Assert.That(eventFired, Is.True); }
public void Test() { MainForm testedForm = new MainForm(); testedForm.Show(); ButtonTester buttonTester = new ButtonTester("button1", "MainForm"); Assert.That(buttonTester.Text, Is.EqualTo("Start \"Worker\"")); buttonTester.Click(); }
/// <summary> /// Tests the buttons of the program /// </summary> /// <returns></returns> public bool GuiTest() { ButtonTester openTester = new ButtonTester("btnOpen", "TestForm"); ExpectFileDialog(openFileDialogHandler); openTester.Click(); ButtonTester saveTester = new ButtonTester("btnSave", "TestForm"); ExpectFileDialog(saveFileDialogHandler); saveTester.Click(); ButtonTester schemaTester = new ButtonTester("btnSchema", "TestForm"); ExpectFileDialog(schemaFileDialogHandler); schemaTester.Click(); return true; }
public override void Setup() { base.Setup(); m_usernameTextbox = new TextBoxTester("m_usernameTextbox"); m_connectButton = new ButtonTester("m_connectButton"); m_disconnectbutton = new ButtonTester("m_disconnectbutton"); m_sendMsgButton = new ButtonTester("m_sendMsgButton"); m_sendMsgAsyncButton = new ButtonTester("m_sendMsgAsyncButton"); m_connectedLabel = new LabelTester("m_constatus"); m_messageTextbox = new TextBoxTester("m_messageTextbox"); m_messagesTester = new ListBoxTester("m_messages"); m_client = new Client("localhost", 8087, 0); m_chatform = m_client.CreateChatForm(); m_chatform.Show(); m_usernameTextbox.Enter("test"); m_connectButton.Click(); }
public void PersonListView_EditButtonPressed_FiresEvent() { // Arrange bool EditButtonEventFired = false; PersonListView view = new PersonListView(); view.EditButtonPressed += new ViewEvent(delegate { EditButtonEventFired = true; }); view.Show(); ButtonTester loadTester = new ButtonTester("btnEdit"); //Act loadTester.Click(); // Assert Assert.IsTrue(EditButtonEventFired, "EditButtonPressed doesn't fire event"); // Cleanup view.Close(); }
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(); }
public void ConfirmModalByYes() { var t = new ButtonTester("Yes"); t.Click(); }
///<summary> /// Clicks the named control. ///</summary> public void Click(string controlName) { ButtonTester button = new ButtonTester(controlName, targetForm.Properties); button.Click(); }
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"); }
public void Updating () { ButtonTester buttonTester = new ButtonTester("update", form); monitor.ServiceFactory = new StoleScreenShotWhileUpdating(this); buttonTester.Click(); }
/// <summary> /// Handler for the ExchangeRateUsage1 test /// </summary> public void ExchangeRateUsageHandler() { FormTester formTester = new FormTester(FModalFormName); // 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 { for (int i = 7; i > 0; i--) { SelectRowInGrid(i); string Usage = ((TFrmSetupDailyExchangeRate)formTester.Properties).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.5225 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:113"), "Expected a reference to Batch 113, 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-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 2: // 0.5225 Assert.IsTrue(Usage.ToLower().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 3: // 0.5225 Assert.IsTrue(Usage.ToLower().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 4: // 0.5225 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:24"), "Expected a reference to Batch 24, 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-15"), "Expected a reference to a date of 2000-10-15, 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.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:23"), "Expected a reference to Batch 23, 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-09"), "Expected a reference to a date of 2000-10-09, 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.ToLower().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); Assert.IsTrue(Usage.Contains("Time:0"), "Expected a reference to Time 0, but was: " + Usage); break; case 7: // 0.5155 Assert.IsTrue(Usage.ToLower().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 22, 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 8: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:103"), "Expected a reference to Batch 103, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, 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:60"), "Expected a reference to Time 60, but was: " + Usage); break; case 9: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:17"), "Expected a reference to Batch 17, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, 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 10: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:102"), "Expected a reference to Batch 102, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, 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:60"), "Expected a reference to Time 60, but was: " + Usage); break; case 11: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains("status:posted"), "Expected a posted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:16"), "Expected a reference to Batch 16, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, 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 12: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains( "status:unposted"), "Expected an unposted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:101"), "Expected a reference to Batch 101, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:1"), "Expected a reference to Journal 1, 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:60"), "Expected a reference to Time 60, but was: " + Usage); break; case 13: // 0.5155 Assert.IsTrue(Usage.ToLower().Contains("status:posted"), "Expected a posted row in Gift Batch table, but was: " + Usage); Assert.IsTrue(Usage.Contains("Batch:15"), "Expected a reference to Batch 15, but was: " + Usage); Assert.IsTrue(Usage.Contains("Journal:0"), "Expected a reference to Journal 0, 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(); } }
public void TestImportGLBatch() { int NumberOfBatches = 0; 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); TFrmGLBatch frmBatch1 = new TFrmGLBatch(null); //Open the batch form and count no. of batches frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); TSgrdDataGridPagedTester grdDetails = new TSgrdDataGridPagedTester("grdDetails"); NumberOfBatches = grdDetails.Count - 1; TLogging.Log("NumberOfBatches: " + NumberOfBatches.ToString()); //Close the form frmBatch.Close(); 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); }; //Set the batch form to open with importing batches dialog frmBatch1.LoadForImport = true; frmBatch1.LedgerNumber = FLedgerNumber; frmBatch1.Show(); TSgrdDataGridPagedTester grdDetails1 = new TSgrdDataGridPagedTester("grdDetails"); TLogging.Log("grdDetails.Count after import: " + grdDetails1.Count.ToString()); Assert.AreNotEqual(NumberOfBatches, grdDetails1.Count, "The grid should include imported batches"); frmBatch1.Close(); }
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(); }
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); mainScreen.SaveChanges(); mainScreen.Close(); }
public void AddRowToEmptyTable() { FMainDS.LoadAll(); FMainDS.DeleteAllRows(); 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; 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 baseCurrency = GetDefaultBaseCurrency(); string expectedFromCurrency = "USD"; if (baseCurrency == "USD") { expectedFromCurrency = "GBP"; } DateTime expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); // Check the details panel after adding the new row Assert.AreEqual(expectedFromCurrency, cmbFromCurrency.GetSelectedString()); Assert.AreEqual(baseCurrency, cmbToCurrency.GetSelectedString()); Assert.AreEqual(expectedDate, dtpEffectiveDate.Date); Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal); // Set a valid exchange rate and save txtExchangeRate.NumberValueDecimal = 2.0m; 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(expectedFromCurrency, cmbFromCurrency.GetSelectedString()); Assert.AreEqual(baseCurrency, cmbToCurrency.GetSelectedString()); Assert.AreEqual(expectedDate, dtpEffectiveDate.Date); Assert.AreEqual(2.0m, txtExchangeRate.NumberValueDecimal); // Now select the inverese row SelectRowInGrid(2); // Check the details are, in fact, the inverse Assert.AreEqual(baseCurrency, cmbFromCurrency.GetSelectedString()); Assert.AreEqual(expectedFromCurrency, cmbToCurrency.GetSelectedString()); Assert.AreEqual(expectedDate, dtpEffectiveDate.Date); Assert.AreEqual(0.5m, txtExchangeRate.NumberValueDecimal); mainScreen.Close(); }
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"); }
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(); }
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(); }
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.IsFalse(dtpEffectiveDate.Enabled); Assert.IsFalse(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()); // 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(); }
/// <summary> /// Handler for LoadModalTableWithData test /// </summary> public void LoadModalTableHandler() { // 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 { Assert.AreEqual("GBP", 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(new DateTime(1900, 7, 1), dtpDateEffective.Date); Assert.AreEqual(0.51m, txtRateOfExchange.NumberValueDecimal); Assert.IsFalse(cmbFromCurrency.Enabled); Assert.IsFalse(cmbToCurrency.Enabled); Assert.IsTrue(btnClose.Enabled); Assert.IsTrue(btnClose.Visible); Assert.IsTrue(btnCancelTester.Properties.Visible); Assert.IsTrue(btnDelete.Enabled); Assert.IsTrue(pnlDetails.Enabled); Assert.AreEqual(3, grdDetails.Rows.Count); // select this item and close btnCloseTester.Click(); } catch (Exception ex) { // Handle the exception and abort without saving HandleModalException(ex); btnCancelTester.Properties.DialogResult = DialogResult.Abort; btnCancelTester.Click(); } }
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 is disabled, then add one new row and check it is now enabled Assert.IsFalse(btnInvert.Properties.Enabled); 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); mainScreen.SaveChanges(); mainScreen.Close(); }
/// <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(); } }
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(); }
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(); }
// /// <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(); }
/// <summary> /// Handler for ModalEmptyTable test /// </summary> public void LoadModalEmptyTableHandler() { // 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 { Assert.IsFalse(btnClose.Enabled); Assert.IsFalse(btnDelete.Enabled); Assert.IsFalse(dtpDateEffective.Date.HasValue); Assert.IsFalse(pnlDetails.Enabled); Assert.AreEqual(1, grdDetails.Rows.Count); // Now create a new row btnNewTester.Click(); // These should be the states after adding a new row Assert.AreEqual("GBP", cmbFromCurrency.GetSelectedString()); // GBP passed in as a ShowDialog parameter 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(0.0m, txtRateOfExchange.NumberValueDecimal); txtRateOfExchange.NumberValueDecimal = STANDARD_RATE_OF_EXCHANGE; // Save this as our rate and quit btnCloseTester.Click(); } catch (Exception ex) { // Handle the exception and abort without saving HandleModalException(ex); btnCancelTester.Properties.DialogResult = DialogResult.Abort; btnCancelTester.Click(); } }