Exemplo n.º 1
0
//        /// <summary>
//        /// simple test to create a batch and save it
//        /// </summary>
//        [Test]
//        public void TestCreateBatchAndSave()
//        {
//            TFrmGiftBatch frmBatch = new TFrmGiftBatch(IntPtr.Zero);
//
//            frmBatch.LedgerNumber = FLedgerNumber;
//            frmBatch.Show();
//
//            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");
//            ButtonTester btnNewBatch = new ButtonTester("ucoBatches.btnNew");
//
//            Assert.AreEqual(false, btnSave.Properties.Enabled, "Save button should be disabled since there are no changes");
//            btnNewBatch.Click();
//
//            TextBoxTester txtDetailBatchDescription = new TextBoxTester("txtDetailBatchDescription");
//            txtDetailBatchDescription.Properties.Text = "Created by test TestCreateBatchAndSave";
//
//            Assert.AreEqual(true, btnSave.Properties.Enabled, "Save button should be enabled since there was a change");
//            btnSave.Click();
//        }

        private void ImportGiftBatch(string TestFile)
        {
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

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

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat          = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "MM/dd/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;
                    ComboBoxTester cmbNumberFormat = new ComboBoxTester("cmbNumberFormat");
                    cmbNumberFormat.Select(0);
                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    ModalFormHandler = delegate(string name3, IntPtr hWnd3, Form form3)
                    {
                        MessageBoxTester tester3 = new MessageBoxTester(hWnd3);
                        Assert.AreEqual("Success", tester3.Title);
                        tester3.SendCommand(MessageBoxTester.Command.OK);
                    };
                    btnOK.Click();
                };
                tester.OpenFile(TestFile);
            };

            ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches");

            btnImport.Click();
        }
Exemplo n.º 2
0
        private static void AbreArchivo(string elArchivo)
        {
            // Crea el camino absoluto al archivo.
            string archivoParaAbrir = Path.Combine(miDirectorioDeData, elArchivo);

            archivoParaAbrir = Path.GetFullPath(archivoParaAbrir);

            // Instala un manejador que espere por la ventana de abrir archivo.
            using (ModalFormTester probadorDeForma = new ModalFormTester())
            {
                probadorDeForma.ExpectModal("Open", delegate
                {
                    OpenFileDialogTester formaAbrirArchivo = new OpenFileDialogTester("Open");

                    // Manda a abrir el arhivo.
                    // Por alguna razón desconocida, la llamada a OpenFile a veces no
                    // funciona. Llamamos la misma función 10 veces para
                    // asegurarnos que funciona.
                    for (int i = 0; i < 10; ++i)
                    {
                        formaAbrirArchivo.OpenFile(archivoParaAbrir);
                        Thread.Sleep(100);
                    }
                }
                                            );

                // Selecciona el menú de abrir archivo.
                ToolStripMenuItemTester menuAbrirArchivo = new ToolStripMenuItemTester("miMenuAbrirArchivo");
                menuAbrirArchivo.Click();
            }
        }
Exemplo n.º 3
0
        ///<summary>
        /// Modal handler to click the open button.
        ///</summary>
        public void OpenFileHandler()
        {
            OpenFileDialogTester dlg_tester = new OpenFileDialogTester("Open");
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NUnitForms.dll");

            dlg_tester.OpenFile(fileName);
        }
Exemplo n.º 4
0
        ///<summary>
        /// Modal handler to click the open button.
        ///</summary>
        public void OpenFileHandler(string name, System.IntPtr hWnd, System.Windows.Forms.Form form)
        {
            OpenFileDialogTester dlg_tester = new OpenFileDialogTester(hWnd);
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XunitForms.dll");

            dlg_tester.OpenFile(fileName);
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        public void GetSourceFileLocation_CancelClicked_ResultFileSelectedIsFalse()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var helper = new DialogBasedInquiryHelper(dialogParent);

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new OpenFileDialogTester(wnd);
                tester.ClickCancel();
            };

            // Call
            string result = helper.GetSourceFileLocation(new FileFilterGenerator().Filter);

            // Assert
            Assert.IsNull(result);
        }
Exemplo n.º 7
0
        public void GetSourceFileLocation_Always_ShowsOpenFileDialog()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var helper = new DialogBasedInquiryHelper(dialogParent);

            string windowName = null;

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new OpenFileDialogTester(wnd);
                windowName = name;
                tester.ClickCancel();
            };

            // Call
            helper.GetSourceFileLocation(new FileFilterGenerator().Filter);

            // Assert
            Assert.AreEqual("Openen", windowName);
        }
Exemplo n.º 8
0
        public void GetSourceFileLocation_ExistingFileSelected_ResultFileSelectedIsTrueFileNameSet()
        {
            // Setup
            dialogParent.Expect(d => d.Handle).Repeat.AtLeastOnce().Return(default(IntPtr));
            mocks.ReplayAll();

            var    helper           = new DialogBasedInquiryHelper(dialogParent);
            string expectedFilePath = Path.GetFullPath(Path.GetRandomFileName());

            DialogBoxHandler = (name, wnd) =>
            {
                var tester = new OpenFileDialogTester(wnd);
                tester.OpenFile(expectedFilePath);
            };

            using (new FileDisposeHelper(expectedFilePath))
            {
                // Call
                string result = helper.GetSourceFileLocation(new FileFilterGenerator().Filter);

                // Assert
                Assert.AreEqual(expectedFilePath, result);
            }
        }
Exemplo n.º 9
0
        public void TestImportExportGLBatch()
        {
            // create two test batches, with some strange figures, to test problem with double values
            // export the 2 test batches, with summarize option
            // compare the exported text file

            string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/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();
        }
Exemplo n.º 10
0
        public static void OpenFile_Cancel_Handler(string name, IntPtr hWnd, Form form)
        {
            var openDlg = new OpenFileDialogTester(hWnd);

            openDlg.ClickCancel();
        }
Exemplo n.º 11
0
        protected override void OnShown(AllorsEventOccuredEventArgs args)
        {
            switch (this.testCaseSwitch)
            {
            case TestCaseSwitch.OpenRepository:
                switch (++this.OnShownCount)
                {
                case 1:
                    var openFileDialogTester = new OpenFileDialogTester(args.Tester);
                    openFileDialogTester.Target.DialogResult = DialogResult.OK;
                    openFileDialogTester.Target.FileName     = RepositoryFile.FullName;
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.AddSuperDomain:
                switch (++this.OnShownCount)
                {
                case 1:
                    var openFileDialogTester = new OpenFileDialogTester(args.Tester);
                    openFileDialogTester.Target.DialogResult = DialogResult.OK;
                    openFileDialogTester.Target.FileName     = this.SuperDomainRepositoryFileInfo.FullName;
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.DeleteType:
                switch (++this.OnShownCount)
                {
                case 1:
                    var messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("Do you really want to delete Singular and all its relations?", messageBoxTester.Target.Text);
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.DeleteTypeWithCascading:
                switch (++this.OnShownCount)
                {
                case 1:
                    var deleteMessageBoxTester = new MessageBoxTester(args.Tester);
                    deleteMessageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("Do you really want to delete Singular and all its relations?", deleteMessageBoxTester.Target.Text);
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.DeleteRelation:
                switch (++this.OnShownCount)
                {
                case 1:
                    var messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("Do you really want to delete Singular.AllorsString?", messageBoxTester.Target.Text);
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.DeleteSuperDomain:
                switch (++this.OnShownCount)
                {
                case 1:
                    var messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("Do you really want to delete SuperDomain?", messageBoxTester.Target.Text);
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.UpdateTemplate:
                switch (++this.OnShownCount)
                {
                case 1:
                    var messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("Could not update template\n\nTemplate Url can not be null.", messageBoxTester.Target.Text);
                    break;

                case 2:
                    messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.IsTrue(messageBoxTester.Target.Text.StartsWith("Could not update template\n\nMissing property TemplateName"));
                    break;

                case 3:
                    messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.IsTrue(messageBoxTester.Target.Text.StartsWith("Could not update template"));
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            case TestCaseSwitch.Generate:
                switch (++this.OnShownCount)
                {
                case 1:
                    var messageBoxTester = new MessageBoxTester(args.Tester);
                    messageBoxTester.Target.DialogResult = DialogResult.OK;
                    Assert.AreEqual("No templates defined.", messageBoxTester.Target.Text);
                    break;

                default:
                    throw new Exception("No event handler for Onshown");
                }

                break;

            default:
                throw new Exception("No event handler for Onshown");
            }
        }
Exemplo n.º 12
0
        ///<summary>
        /// Modal handler to click the cancel button.
        ///</summary>
        public void CancelFileHandler(string name, System.IntPtr hWnd, System.Windows.Forms.Form form)
        {
            OpenFileDialogTester dlg_tester = new OpenFileDialogTester(hWnd);

            dlg_tester.ClickCancel();
        }
 ///<summary>
 /// Modal handler to click the open button.
 ///</summary>
 public void OpenFileHandler()
 {
     OpenFileDialogTester dlg_tester = new OpenFileDialogTester("Open");
     string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XunitForms.dll");
     dlg_tester.OpenFile(fileName);
 }
Exemplo n.º 14
0
        ///<summary>
        /// Modal handler to click the cancel button.
        ///</summary>
        public void CancelFileHandler()
        {
            OpenFileDialogTester dlg_tester = new OpenFileDialogTester("Open");

            dlg_tester.ClickCancel();
        }
Exemplo n.º 15
0
 ///<summary>
 /// Modal handler to click the open button.
 ///</summary>
 public void OpenFileHandler(string name, System.IntPtr hWnd, System.Windows.Forms.Form form)
 {
     OpenFileDialogTester dlg_tester = new OpenFileDialogTester(hWnd);
     string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XunitForms.dll");
     dlg_tester.OpenFile(fileName);
 }
Exemplo n.º 16
0
 ///<summary>
 /// Modal handler to click the cancel button.
 ///</summary>
 public void CancelFileHandler(string name, System.IntPtr hWnd, System.Windows.Forms.Form form)
 {
     OpenFileDialogTester dlg_tester = new OpenFileDialogTester(hWnd);
     dlg_tester.ClickCancel();
 }
Exemplo n.º 17
0
        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");
        }
 ///<summary>
 /// Modal handler to click the cancel button.
 ///</summary>
 public void CancelFileHandler()
 {
     OpenFileDialogTester dlg_tester = new OpenFileDialogTester("Open");
     dlg_tester.ClickCancel();
 }