public void TestPostAndSaveAfterwards() { string TestFile = CommonNUnitFunctions.rootPath + "/csharp/ICT/Testing/lib/MFinance/GiftForm/TestData/BatchImportTest.csv"; TFrmGiftBatch frmBatch = new TFrmGiftBatch(null); frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); ImportGiftBatch(TestFile); TabControlTester tabGiftBatch = new TabControlTester("tabGiftBatch"); tabGiftBatch.SelectTab(1); TextBoxTester txtDetailGiftTransactionAmount = new TextBoxTester("txtDetailGiftTransactionAmount"); Assert.AreEqual(Convert.ToDecimal(txtDetailGiftTransactionAmount.Properties.Text), 10000000000M); frmBatch.Close(); }
public void TestImportExportGiftBatch() { // create two test batches, with some strange figures, to test problem with double values // TODO export the 2 test batches, with summarize option // TODO compare the exported text file string TestFile = CommonNUnitFunctions.rootPath + "/csharp/ICT/Testing/lib/MFinance/GiftForm/TestData/BatchImportTest.csv"; TFrmGiftBatch frmBatch = new TFrmGiftBatch(null); frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); ImportGiftBatch(TestFile); TabControlTester tabGiftBatch = new TabControlTester("tabGiftBatch"); tabGiftBatch.SelectTab(1); TextBoxTester txtDetailGiftTransactionAmount = new TextBoxTester("txtDetailGiftTransactionAmount"); Assert.AreEqual(Convert.ToDecimal(txtDetailGiftTransactionAmount.Properties.Text), 10000000000M); frmBatch.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 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 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") + "/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(); }
public void PruebaProcesamientoDeTodo() { #region Preparación. // Comienza applicación. InterfaseManejadorDeMapa interfaseManejadorDeMapa = new InterfaseManejadorDeMapa(); interfaseManejadorDeMapa.Show(); interfaseManejadorDeMapa.TopMost = true; // Crea los probadores de los elementos de la interfase. TabControlTester controladorDePestañasPrincipal = new TabControlTester("miControladorDePestañasPrincipal"); TabControlTester controladorDePestañasDePdis = new TabControlTester("miInterfaseManejadorDePdis.miControladorDePestañas"); TabControl.TabPageCollection pestañasPdis = controladorDePestañasDePdis.Properties.TabPages; TabPage pestañaTodos = pestañasPdis[1]; TabPage pestañaModificados = pestañasPdis[2]; TabPage pestañaEliminados = pestañasPdis[3]; TabPage pestañaPosiblesDuplicados = pestañasPdis[4]; TabPage pestañaAlertas = pestañasPdis[5]; TabPage pestañaErrores = pestañasPdis[6]; #endregion CasoDeProcesamientoDePdis[] casos = new[] { // Archivo, Todos, Modificados, Duplicados, Eliminados, Alertas, Errores new CasoDeProcesamientoDePdis( "58090.mp", 1713, 177, 20, 2, 0, 80), new CasoDeProcesamientoDePdis( "58170.mp", 6837, 545, 13, 189, 0, 230), new CasoDeProcesamientoDePdis( "58220.mp", 6460, 932, 34, 58, 0, 191), new CasoDeProcesamientoDePdis( "58370.mp", 1808, 235, 47, 8, 0, 252), new CasoDeProcesamientoDePdis( "58460.mp", 980, 85, 151, 4, 0, 225), }; foreach (CasoDeProcesamientoDePdis caso in casos) { AbreArchivo(caso.Archivo); // Verifica el número de PDIs en las pestañas. string identificación = "[" + caso.Archivo + "]"; Assert.AreEqual("Todos (" + caso.Todos + ")", pestañaTodos.Text, identificación + "PDIs.Todos.Text"); Assert.AreEqual("Modificados (0)", pestañaModificados.Text, identificación + "PDIs.Modificados.Text"); Assert.AreEqual("Eliminados (0)", pestañaEliminados.Text, identificación + "PDIs.Eliminados.Text"); Assert.AreEqual("Posibles Duplicados", pestañaPosiblesDuplicados.Text, identificación + "PDIs.PosiblesDuplicados.Text"); Assert.AreEqual("Alertas", pestañaAlertas.Text, identificación + "PDIs.Alertas.Text"); Assert.AreEqual("Errores", pestañaErrores.Text, identificación + "PDIs.Errores.Text"); // Selecciona la pestaña de PDIs. controladorDePestañasPrincipal.SelectTab(2); // Manda a procesar todo. ToolStripMenuItemTester menuProcesarTodo = new ToolStripMenuItemTester("miMenúProcesarTodo"); menuProcesarTodo.Click(); // Verifica el número de PDIs en las pestañas. Assert.AreEqual("Todos (" + caso.Todos + ")", pestañaTodos.Text, identificación + "PDIs.Todos.Text"); Assert.AreEqual("Modificados (" + caso.Modificados + ")", pestañaModificados.Text, identificación + "PDIs.Modificados.Text"); Assert.AreEqual("Eliminados (" + caso.Eliminados + ")", pestañaEliminados.Text, identificación + "PDIs.Eliminados.Text"); Assert.AreEqual("Posibles Duplicados (" + caso.PosiblesDuplicados + ")", pestañaPosiblesDuplicados.Text, identificación + "PDIs.PosiblesDuplicados.Text"); Assert.AreEqual("Alertas (" + caso.Alertas + ")", pestañaAlertas.Text, identificación + "PDIs.Alertas.Text"); Assert.AreEqual("Errores (" + caso.Errores + ")", pestañaErrores.Text, identificación + "PDIs.Errores.Text"); } // Cerrar la applicación. ToolStripMenuItemTester menúSalir = new ToolStripMenuItemTester("miMenuSalir"); menúSalir.Click(); }