public void SelectOption() { RadioButtonTester rbRed = new RadioButtonTester("rbRed"); LabelTester lblSelectedColor = new LabelTester("lblSelectedColor"); RadioButtonTester rbOrange = new RadioButtonTester("rbOrange"); RadioButtonTester rbGreen = new RadioButtonTester("rbGreen"); RadioButtonTester rbYellow = new RadioButtonTester("rbYellow"); RadioButtonTester rbBlue = new RadioButtonTester("rbBlue"); RadioButtonTester rbIndigo = new RadioButtonTester("rbIndigo"); RadioButtonTester rbViolet = new RadioButtonTester("rbViolet"); rbRed.Click(); Assert.AreEqual("Red", lblSelectedColor.Properties.Text); Assert.AreEqual(true, rbRed.Properties.Checked); Assert.AreEqual(false, rbOrange.Properties.Checked); Assert.AreEqual("Red", rbRed.Text); Assert.AreEqual("Red", rbRed.Properties.Text); rbOrange.Click(); Assert.AreEqual("Orange", lblSelectedColor.Properties.Text); Assert.AreEqual(false, rbRed.Properties.Checked); Assert.AreEqual(true, rbOrange.Properties.Checked); Assert.AreEqual("Orange", rbOrange.Text); Assert.AreEqual("Orange", rbOrange.Properties.Text); }
// /// <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(); }
public void Click() { RadioButtonTestForm form = new RadioButtonTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.AreEqual("", writer.Test); RadioButtonTester red = new RadioButtonTester("rbRed", form); RadioButtonTester orange = new RadioButtonTester("rbOrange", form); red.Click(); orange.Click(); Assert.AreEqual( @"[Test] public void Test() { RadioButtonTester rbRed = new RadioButtonTester(""rbRed""); RadioButtonTester rbOrange = new RadioButtonTester(""rbOrange""); rbRed.Click(); rbOrange.Click(); }", writer.Test); }
public static void PersonsFilterDlg_Handler(Form form) { PersonsFilterDlg pfDlg = (PersonsFilterDlg)form; SelectTab("tabsFilters", form, 1); ClickRadioButton("rgLife.rbAliveBefore", form); ClickRadioButton("rgLife.rbAll", form); var rbSexMale = new RadioButtonTester("rbSexMale", form); rbSexMale.Properties.Checked = true; var rbOnlyLive = new RadioButtonTester("rbOnlyLive", form); rbOnlyLive.Properties.Checked = true; EnterCombo("txtName", form, "*Ivan*"); EnterCombo("cmbResidence", form, "*test place*"); EnterCombo("cmbEventVal", form, "*test event*"); EnterCombo("cmbGroup", form, "- any -"); EnterCombo("cmbSource", form, "- any -"); }
public static void SexCheckDlgTests_AcceptF_Handler(string name, IntPtr ptr, Form form) { var rbFemale = new RadioButtonTester("rbFemale", form); rbFemale.Properties.Checked = true; ClickButton("btnAccept", form); }
public void Click() { RadioButtonTestForm form = new RadioButtonTestForm(); form.Show(); TestWriter writer = new TestWriter(form); Assert.Equal("", writer.Test); RadioButtonTester red = new RadioButtonTester("rbRed", form); RadioButtonTester orange = new RadioButtonTester("rbOrange", form); red.Click(); orange.Click(); Assert.Equal( @"[Fact] public void Test() { RadioButtonTester rbRed = new RadioButtonTester(""rbRed""); RadioButtonTester rbOrange = new RadioButtonTester(""rbOrange""); rbRed.Click(); rbOrange.Click(); }", writer.Test); }
public void TestAutoPostBack() { RadioButtonTester autoGroup1 = new RadioButtonTester("autoGroup1"); RadioButtonTester autoGroup2 = new RadioButtonTester("autoGroup2"); autoGroup1.Checked = true; Assert.IsTrue(autoGroup1.Checked, "autoGroup1 should be checked"); }
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(); }
protected override void SetUp() { base.SetUp(); Submit = new LinkButtonTester("submit", CurrentWebForm); CheckBox = new RadioButtonTester("radionButton", CurrentWebForm); DisabledCheckBox = new RadioButtonTester("disabled", CurrentWebForm); groupedOne = new RadioButtonTester("groupedOne", CurrentWebForm); groupedTwo = new RadioButtonTester("groupedTwo", CurrentWebForm); Submit = new LinkButtonTester("submit", CurrentWebForm); Browser.GetPage(BaseUrl + "/AspTester/RadioButtonTestPage.aspx"); }
public void Test_EnterDataAndApply() { Assert.IsNotNull(fDialog.Filter); var rbCutPersons = new RadioButtonTester("rbCutPersons", fDialog); rbCutPersons.Click(); var rbCutYears = new RadioButtonTester("rbCutYears", fDialog); rbCutYears.Click(); var rbCutNone = new RadioButtonTester("rbCutNone", fDialog); rbCutNone.Click(); ClickButton("btnAccept", fDialog); }
public static void RecMergeDlg_Handler(string name, IntPtr ptr, Form form) { var tabs = new TabControlTester("tabsTools", form); CheckBox("chkBookmarkMerged", form, true); CheckBox("chkBookmarkMerged", form, false); var radPersons = new RadioButtonTester("radPersons", form); radPersons.Properties.Checked = true; RecordSelectDlgTests.SetSelectItemHandler(0); ClickButton("MergeControl.btnRec1Select", form); RecordSelectDlgTests.SetSelectItemHandler(1); ClickButton("MergeControl.btnRec2Select", form); ClickButton("btnAutoSearch", form); ClickButton("btnSkip", form); form.Close(); }
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 GL batch"), "Should start with 'are you sure you want to post GL batch', but is '" + tester.Text + "'"); // there is a second message box after posting, telling the user about success. // because the ModalFormHandler is reset after handling the first message box, we need to set up a new handler. ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { MessageBoxTester tester2 = new MessageBoxTester(hWnd2); Assert.AreEqual("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 // TODO NUnit.Extensions.Forms.NoSuchControlException : rbtPosting 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 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 TestImportExportGLBatch() { // create two test batches, with some strange figures, to test problem with double values // export the 2 test batches, with summarize option // compare the exported text file string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/lib/MFinance/GLForm/TestData/BatchImportFloatTest.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); TFrmGLBatch frmBatch = new TFrmGLBatch(null); frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); ModalFormHandler = delegate(string name, IntPtr hWnd, Form form) { OpenFileDialogTester tester = new OpenFileDialogTester(hWnd); ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2); TextBoxTester txtDateFormat = new TextBoxTester("txtDateFormat"); txtDateFormat.Properties.Text = "MM/dd/yyyy"; RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon"); rbtSemicolon.Properties.Checked = true; ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name); btnOK.Click(); }; tester.OpenFile(TestFile); }; ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches"); btnImport.Click(); ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave"); Assert.IsTrue(btnSave.Properties.Enabled, "Save button has not been activated"); btnSave.Click(); // go to Journal tab TabControlTester tabGLBatch = new TabControlTester("tabGLBatch"); tabGLBatch.SelectTab(1); TextBoxTester txtBatchNumber = new TextBoxTester("ucoJournals.txtBatchNumber"); // get the batch number from the journal tab int ImportedBatchNumber = Convert.ToInt32(txtBatchNumber.Properties.Text); TFrmGLBatchExport frmBatchExport = new TFrmGLBatchExport(null); frmBatch.Close(); // export that batch, summarize the transactions // compare the result with the expected file frmBatchExport.LedgerNumber = FLedgerNumber; frmBatchExport.Show(); CheckBoxTester chkIncludeUnposted = new CheckBoxTester("chkIncludeUnposted"); chkIncludeUnposted.Properties.Checked = true; RadioButtonTester rbtSummary = new RadioButtonTester("rbtSummary"); rbtSummary.Properties.Checked = false; RadioButtonTester rbtBatchNumberSelection = new RadioButtonTester("rbtBatchNumberSelection"); rbtBatchNumberSelection.Properties.Checked = true; TextBoxTester txtFilename = new TextBoxTester("txtFilename"); TTxtNumericTextBoxTester txtBatchNumberStart = new TTxtNumericTextBoxTester("txtBatchNumberStart"); txtBatchNumberStart.Properties.NumberValueInt = ImportedBatchNumber; TTxtNumericTextBoxTester txtBatchNumberEnd = new TTxtNumericTextBoxTester("txtBatchNumberEnd"); txtBatchNumberEnd.Properties.NumberValueInt = ImportedBatchNumber; // Test simple export of batches, no summary TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTest.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); txtFilename.Properties.Text = TestFile + ".new"; ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { MessageBoxTester tester2 = new MessageBoxTester(hWnd2); // Assert.AreEqual("Success", tester.Title); tester2.SendCommand(MessageBoxTester.Command.OK); }; frmBatchExport.ExportBatches(false); Assert.AreEqual(true, TTextFile.SameContent(TestFile, TestFile + ".new"), "the files should be the same: " + TestFile); System.IO.File.Delete(TestFile + ".new"); // Test export of batches, summarizing the transactions TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTestSummary.csv"; TestFile = Path.GetFullPath(TestFile); Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile); txtFilename.Properties.Text = TestFile + ".new"; rbtSummary.Properties.Checked = true; ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2) { MessageBoxTester tester2 = new MessageBoxTester(hWnd2); // Assert.AreEqual("Success", tester.Title); tester2.SendCommand(MessageBoxTester.Command.OK); }; frmBatchExport.ExportBatches(false); Assert.AreEqual(true, TTextFile.SameContent(TestFile, TestFile + ".new"), "the files should be the same: " + TestFile); System.IO.File.Delete(TestFile + ".new"); frmBatchExport.Close(); }
public static void ClickRadioButton(string name, Form form) { var radBtn = new RadioButtonTester(name, form); radBtn.Click(); }