public void SetValues_Reopen_HasSameValues() { using (TemporaryFolder tempFolder = new TemporaryFolder("backupPlanControlTests")) { try { CreateNewAndGotoBackupControl(tempFolder.FolderPath); TextBoxTester t = new TextBoxTester("_pathText"); t.Properties.Text = @"q:\"; CloseApp(); //now reopen OpenExisting(tempFolder.FolderPath); GoToBackupTab(); t = new TextBoxTester("_pathText"); Assert.AreEqual(@"q:\", t.Properties.Text); } finally { CloseApp(); } } }
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 TestCreateBatchAndSave() { TFrmGLBatch frmBatch = new TFrmGLBatch(null); frmBatch.LedgerNumber = FLedgerNumber; frmBatch.Show(); ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave"); ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew"); Assert.AreEqual(false, btnSave.Properties.Enabled, "Save button should be disabled since there are no changes"); btnNewBatch.Click(); TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription"); txtDetailBatchDescription.Properties.Text = "Created by test TestCreateBatchAndSave"; Assert.AreEqual(true, btnSave.Properties.Enabled, "Save button should be enabled since there was a change"); btnSave.Click(); }
private void LexicalFormMustMatch(string value) { TextBoxTester t = new TextBoxTester(GetLexicalFormControlName(), _window); Assert.AreEqual(value, t.Properties.Text); }
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 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 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 FindText_EnterWordNotInDictionaryThenPressCtrlN_AddsWordInFindText() { TextBoxTester t = new TextBoxTester("_findText", _window); t.Enter("NewWord"); PressCtrlN(t); VerifySelectedWordIs("NewWord"); }
public void FindText_EnterWordInDictionaryThenPressCtrlN_AddsWordInFindTextSoTwoEntries() { TextBoxTester t = new TextBoxTester("_findText", _window); t.Enter("Secondary"); PressCtrlN(t); VerifySelectedWordIs("Secondary"); Assert.AreEqual(2, _lexEntryRepository.GetEntriesWithMatchingLexicalForm("Secondary", _vernacularWritingSystem) .Count); }
public void FindText_EnterTextOneCharacterAtATime_DoesNotThrow() { TextBoxTester t = new TextBoxTester("_findText", _window); //This is a beter test but gives a cryptic error message //KeyboardController keyboardController = new KeyboardController(t); //t.Properties.Focus(); //keyboardController.Press("Test"); //keyboardController.Press("e"); //keyboardController.Press("s"); //keyboardController.Press("t"); //keyboardController.Dispose(); t.Enter("Test"); t.FireEvent("TextChanged", new EventArgs()); Assert.AreEqual("Test", t.Text); }
public void FindText_Enter_Finds() { TextBoxTester t = new TextBoxTester("_findText", _window); t.Enter("Secondary"); t.FireEvent("KeyDown", new KeyEventArgs(Keys.Enter)); ListViewTester l = new ListViewTester("_recordsListBox", _window); string label = GetSelectedLabel((WeSayListView) l.Properties); Assert.AreEqual("Secondary", label); }
public void FindText_EnterTextThenPressFindButton_Finds() { TextBoxTester t = new TextBoxTester("_findText", _window); t.Enter("Secondary"); ClickFindButton(); ListViewTester l = new ListViewTester("_recordsListBox", _window); string label = GetSelectedLabel((WeSayListView) l.Properties); Assert.AreEqual("Secondary", label); RichTextBoxTester r = new RichTextBoxTester("_lexicalEntryPreview", _window); Assert.IsTrue(r.Text.Contains("secondarymeaning")); }
private void TypeInMeaning(string value) { TextBoxTester t = new TextBoxTester(GetMeaningControlName(), _window); t.Properties.Text = value; }
private void TypeInLexicalForm(string value) { TextBoxTester t = new TextBoxTester(GetLexicalFormControlName(), _window); t.Properties.Text = value; //change the focus ShiftFocus(); }
// public ToolStripMenuItemTester mniFile; // public System.Windows.Forms.ToolStripMenuItem mniFileSave; // public System.Windows.Forms.ToolStripSeparator mniSeparator0; // public System.Windows.Forms.ToolStripMenuItem mniFilePrint; // public System.Windows.Forms.ToolStripSeparator mniSeparator1; // public System.Windows.Forms.ToolStripMenuItem mniClose; // public System.Windows.Forms.ToolStripMenuItem mniEdit; // public System.Windows.Forms.ToolStripMenuItem mniEditUndoCurrentField; // public System.Windows.Forms.ToolStripMenuItem mniEditUndoScreen; // public System.Windows.Forms.ToolStripSeparator mniSeparator2; // public System.Windows.Forms.ToolStripMenuItem mniEditFind; // public System.Windows.Forms.ToolStripMenuItem mniAccounts; // public System.Windows.Forms.ToolStripMenuItem mniAddNewAccount; // public System.Windows.Forms.ToolStripMenuItem mniDeleteUnusedAccount; // public System.Windows.Forms.ToolStripSeparator mniSeparator3; // public System.Windows.Forms.ToolStripMenuItem mniExportHierarchy; // public System.Windows.Forms.ToolStripMenuItem mniImportHierarchy; // public System.Windows.Forms.ToolStripMenuItem mniHelp; // public System.Windows.Forms.ToolStripMenuItem mniHelpPetraHelp; // public System.Windows.Forms.ToolStripSeparator mniSeparator4; // public System.Windows.Forms.ToolStripMenuItem mniHelpBugReport; // public System.Windows.Forms.ToolStripSeparator mniSeparator5; // public System.Windows.Forms.ToolStripMenuItem mniHelpAboutPetra; // public System.Windows.Forms.ToolStripMenuItem mniHelpDevelopmentTeam; // Contructor which initializes the acces to all the controls on the // Dialog /// <summary> /// ... /// </summary> public TFrmGLAccountHierarchyTester() { mainForm = new TFrmGLAccountHierarchy(null); trvAccounts = new TTrvTreeViewTester("trvAccounts", mainForm); txtDetailAccountCode = new TextBoxTester("txtDetailAccountCode", mainForm); cmbDetailAccountType = new TCmbAutoCompleteTester("cmbDetailAccountType", mainForm); txtDetailEngAccountCodeLongDesc = new TextBoxTester("txtDetailEngAccountCodeLongDesc", mainForm); txtDetailEngAccountCodeShortDesc = new TextBoxTester("txtDetailEngAccountCodeShortDesc", mainForm); txtDetailAccountCodeLongDesc = new TextBoxTester("txtDetailAccountCodeLongDesc", mainForm); txtDetailAccountCodeShortDesc = new TextBoxTester("txtDetailAccountCodeShortDesc", mainForm); cmbDetailValidCcCombo = new TCmbAutoCompleteTester("cmbDetailValidCcCombo", mainForm); chkDetailBankAccountFlag = new CheckBoxTester("chkDetailBankAccountFlag", mainForm); chkDetailAccountActiveFlag = new CheckBoxTester("chkDetailAccountActiveFlag", mainForm); tbbSave = new ToolStripButtonTester("tbbSave", mainForm); tbbAddNewAccount = new ToolStripButtonTester("tbbAddNewAccount", mainForm); tbbDeleteUnusedAccount = new ToolStripButtonTester("tbbDeleteUnusedAccount", mainForm); tbbExportHierarchy = new ToolStripButtonTester("tbbExportHierarchy", mainForm); tbbImportHierarchy = new ToolStripButtonTester("tbbImportHierarchy", mainForm); chkDetailForeignCurrencyFlag = new CheckBoxTester("chkDetailForeignCurrencyFlag", mainForm); cmbDetailForeignCurrencyCode = new TCmbAutoPopulatedTester("cmbDetailForeignCurrencyCode", mainForm); mniClose = new ToolStripMenuItemTester("mniClose", mainForm); }
public void NewWord_FindTextInDictionary_CreatesNewEmptyWord() { TextBoxTester t = new TextBoxTester("_findText", _window); t.Enter("Secondary"); ClickAddWord(); VerifyNewEmptyWordCreated(); }
public void PruebaShowDialog() { #region Preparación general. // Crea un PDI para las pruebas. IEscuchadorDeEstatus escuchadorDeEstatus = new EscuchadorDeEstatusPorOmisión(); ManejadorDeMapa manejadorDeMapa = new ManejadorDeMapa(escuchadorDeEstatus); string nombre = "Nombre"; Tipo tipo = new Tipo("0xaaaa"); const string clase = "POI"; Coordenadas coordenadas = new Coordenadas(20, 30); List<Campo> campos = new List<Campo> { new CampoNombre (nombre), new CampoTipo (tipo), new CampoCoordenadas (CampoCoordenadas.IdentificadorDeCoordenadas, 0, coordenadas) }; List<Pdi> pdis = new List<Pdi>{new Pdi(manejadorDeMapa, 1, clase, campos)}; #endregion #region Caso 1: Apenas aparece la ventana el usuario apreta "Cambiar" { // En este caso el método Show() debería retornar None, // Y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Apreta el botón de "Cambiar". botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.None, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 2: Apenas aparece la ventana el usuario apreta "Cancelar" { // En este caso el método Show() debería retornar Cancel, // Y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea los probadores de los elementos de la interfase. ButtonTester botónCancelar = new ButtonTester("miBotónCancelar", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Apreta el botón de "Cancelar". botónCancelar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.Cancel, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 3: El usuario cambia el tipo inicial por uno válido. { // En este caso el método Show() debería retornar OK, // y la propiedad TipoNuevo debería ser el tipo nuevo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea un tipo válido. string númeroTipoNuevoVálido = "100"; Tipo tipoNuevoVálido = new Tipo("0x" + númeroTipoNuevoVálido); Assert.IsTrue(CaracterísticasDePdis.Descripciones.ContainsKey(tipoNuevoVálido), "El tipo nuevo debe ser conocido."); // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario poniendo un tipo válido. textoTipoNuevo.Properties.Focus(); textoTipoNuevo.Enter(númeroTipoNuevoVálido); // Apreta el botón de "Cambiar". botónCambiar.Properties.Focus(); botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.OK, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(tipoNuevoVálido, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 4: El usuario cambia el tipo inicial por uno desconocido. { // En este caso el método Show() debería retornar None, // y la propiedad TipoNuevo debería ser el tipo desconocido. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea un tipo desconocido. string númeroTipoNuevoDesconocido = "bbbb"; Tipo tipoNuevoDesconocido = new Tipo("0x" + númeroTipoNuevoDesconocido); Assert.IsFalse(CaracterísticasDePdis.Descripciones.ContainsKey(tipoNuevoDesconocido), "El tipo nuevo debe ser desconocido."); // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario poniendo un tipo desconocido. textoTipoNuevo.Properties.Focus(); textoTipoNuevo.Enter(númeroTipoNuevoDesconocido); // Apreta el botón de "Cambiar". botónCambiar.Properties.Focus(); botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.None, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(tipoNuevoDesconocido, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 5: El usuario cambia el tipo inicial por uno inválido. { // En este caso el método Show() debería retornar None, // y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea un tipo inválido. // Un tipo inválido es aquel que genera una excepción cuando // se trata de construir una clase Tipo con el. string númeroTipoNuevoInválido = "ww"; bool tipoEsInválido = false; try { new Tipo("0x" + númeroTipoNuevoInválido); } catch { tipoEsInválido = true; } Assert.IsTrue(tipoEsInválido, "El tipo nuevo debe ser inválido."); // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario poniendo un tipo inválido. textoTipoNuevo.Properties.Focus(); textoTipoNuevo.Enter(númeroTipoNuevoInválido); // Apreta el botón de "Cambiar". botónCambiar.Properties.Focus(); botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.None, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 6: El usuario empiezar a cambiar el tipo, pero al final lo borra y lo deja en blanco. { // En este caso el método Show() debería retornar None, // y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario empezando a cambiar el tipo y despues dejandolo en blanco. textoTipoNuevo.Properties.Focus(); textoTipoNuevo.Enter("123"); textoTipoNuevo.Properties.Text = string.Empty; // Apreta el botón de "Cambiar". botónCambiar.Properties.Focus(); botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.None, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); Assert.AreEqual(pdis, objectoDePrueba.Pdis, "PDIs"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 7: El usuario empiezar a cambiar el tipo, pero al final cancela. { // En este caso el método Show() debería retornar Cancel, // y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = pdis; // Crea los probadores de los elementos de la interfase. ButtonTester botónCancelar = new ButtonTester("miBotónCancelar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario empezando a cambiar el tipo y despues dejandolo en blanco. textoTipoNuevo.Enter("123"); textoTipoNuevo.Properties.Text = string.Empty; // Apreta el botón de "Cancelar". botónCancelar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.Cancel, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion #region Caso 8: Se usa con un PDI nulo. { // En este caso el método Show() debería retornar None, // y la propiedad TipoNuevo debería ser el tipo nulo. #region Preparación. // Inicializa objecto de prueba. VentanaCambiarTipoDePdi objectoDePrueba = new VentanaCambiarTipoDePdi(); objectoDePrueba.Pdis = null; // Crea los probadores de los elementos de la interfase. ButtonTester botónCambiar = new ButtonTester("miBotónCambiar", objectoDePrueba); TextBoxTester textoTipoNuevo = new TextBoxTester("miTextoTipoNuevo", objectoDePrueba); #endregion // Llama al método a probar. objectoDePrueba.Show(); // Simula el usuario empezando a cambiar el tipo y despues dejandolo en blanco. textoTipoNuevo.Properties.Focus(); textoTipoNuevo.Enter("100"); textoTipoNuevo.Properties.Text = string.Empty; // Apreta el botón de "Cambiar". botónCambiar.Properties.Focus(); botónCambiar.Click(); // Probar propiedades. Assert.AreEqual(DialogResult.None, objectoDePrueba.DialogResult, "DialogResult"); Assert.AreEqual(Tipo.TipoNulo, objectoDePrueba.TipoNuevo, "TipoNuevo"); // Cierra la ventana. objectoDePrueba.Close(); } #endregion }
public void BaselineForRemovingSenseTests() { PutCursorInMeaningFieldOfSecondEntry(); TypeInMeaning("samo"); TextBoxTester tb2 = new TextBoxTester(GetMeaningControlName(), _window); Assert.AreEqual("samo", tb2.Properties.Text); }
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(); }
[Test] //regression test public void PastingBlankOverAMeaningOfEmptySenseDoesntCrash() { PutCursorInMeaningFieldOfSecondEntry(); TextBoxTester tb = new TextBoxTester(GetMeaningControlName(), _window); Clipboard.SetText(" "); tb.Properties.Paste(); }
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"); }
[Test] //regression test public void PastingTextOverAMeaningOfEmptySenseDoesntJustChangesMeaning() { PutCursorInMeaningFieldOfSecondEntry(); TextBoxTester tb = new TextBoxTester(GetMeaningControlName(), _window); Clipboard.SetText("samo"); tb.Properties.Paste(); TextBoxTester tb2 = new TextBoxTester(GetMeaningControlName(), _window); Assert.AreEqual("samo", tb2.Properties.Text); }
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 GhostField_Trigger_RegressionTest() { ClickAddWord(); DetailList detailList = GetDetailList(); int initialCount = detailList.Count; FillInTheGhostMeaning(); //ghost really did fire Assert.IsTrue(detailList.Count > initialCount); //now do another one initialCount = detailList.Count; MultiTextControl editControl2 = (MultiTextControl) GetEditControl("Meaning 2", true); Assert.IsTrue(editControl2.Name.Contains("ghost")); editControl2.TextBoxes[0].Focus(); Application.DoEvents(); TextBoxTester t2 = new TextBoxTester(editControl2.TextBoxes[0].Name, _window); t2.Properties.Text = "bar"; Application.DoEvents(); TextBoxTester lxt = new TextBoxTester(GetLexicalFormControlName(), _window); lxt.Properties.Focus(); Application.DoEvents(); Assert.IsTrue(detailList.Count > initialCount); }
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"); }
private void FillInTheGhostMeaning() { MultiTextControl editControl = (MultiTextControl) GetEditControl("Meaning", true); Assert.IsTrue(GetEditControl("Meaning").Name.Contains("ghost")); editControl.TextBoxes[0].Focus(); TextBoxTester t = new TextBoxTester(editControl.TextBoxes[0].Name, _window); //didn''t work t.FireEvent("KeyPress", new KeyPressEventArgs('a')); t.Properties.Text = "foo"; //move focus away Application.DoEvents(); TextBoxTester lxt = new TextBoxTester(GetLexicalFormControlName(), _window); lxt.Properties.Focus(); Application.DoEvents(); }
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 Test_KeyPressMovesFocusToNextControl() { //---------------Set up test pack------------------- GlobalRegistry.UIExceptionNotifier = new RethrowingExceptionNotifier(); var parentControl = _factory.CreateControl(); var strategyWin = new ControlMapperStrategyWin(); var textBox = _factory.CreateTextBox(); textBox.Name = "TestTextBox"; strategyWin.AddKeyPressEventHandler(textBox); parentControl.Controls.Add(textBox); var textBox2 = _factory.CreateTextBox(); parentControl.Controls.Add(textBox2); var tbWin = (TextBoxWin)textBox2; var gotFocus = false; tbWin.GotFocus += delegate { gotFocus = true; }; var frm = AddControlToForm(parentControl); //--------------Assert PreConditions---------------- //---------------Execute Test ---------------------- frm.Show(); var box = new TextBoxTester("TestTextBox"); var eveArgsEnter = new KeyEventArgs(Keys.Enter); box.FireEvent("KeyUp", eveArgsEnter); //---------------Test Result ----------------------- Assert.IsTrue(tbWin.ContainsFocus); Assert.IsTrue(gotFocus); }
// /// <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 SwitchingToAnotherTaskDoesNotLooseBindings() { LexicalFormMustMatch("Initial"); TypeInLexicalForm("one"); _task.Deactivate(); _tabControl.SelectedIndex = 1; _tabControl.SelectedIndex = 0; ActivateTask(); TextBoxTester t = new TextBoxTester(GetLexicalFormControlName(), _window); t.Properties.Visible = true; LexicalFormMustMatch("one"); TypeInLexicalForm("plus"); // need something that still sorts higher than Secondary and Tertiary _task.Deactivate(); _tabControl.SelectedIndex = 1; _tabControl.SelectedIndex = 0; ActivateTask(); t = new TextBoxTester(GetLexicalFormControlName(), _window); t.Properties.Visible = true; LexicalFormMustMatch("plus"); }