public void T04_CreateNewAccountAndChangeTreeViewSelection()
        {
            System.Console.WriteLine("-------T04_CreateNewAccountAndChangeTreeViewSelection------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            int[] nodeList1 =
            {
                0, 2, 1
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList1);

            // Create a first Account ...
            hierarchyTester.tbbAddNewAccount.Click();
            // String strName1 = hierarchyTester.txtDetailAccountCode.Properties.Text;
            // Invalid Name resp. the name "BAL SHT" exists in the test db ...
            hierarchyTester.txtDetailAccountCode.Properties.Text = "BAL SHT";

            // simulate a leave of the message box. It seems selecting another node in the tree would not trigger the leave event in the test
            WaitForMessageBox(MessageBoxTester.Command.OK);
            hierarchyTester.txtDetailAccountCode.FireEvent("Leave");

            Assert.That(lastMessageTitle,
                        Is.StringContaining("You cannot use an account name twice!"),
                        "Error Message shall appear");
            Assert.That(hierarchyTester.trvAccounts.Properties.SelectedNode.Text,
                        Is.StringContaining("NewAccount"),
                        "New Selection shall have been canceled");

            WaitForMessageBox(MessageBoxTester.Command.No);
            hierarchyTester.mniClose.Click();
        }
        public void T05_CreateBankAccount()
        {
            System.Console.WriteLine("-------T05_CreateBankAccount------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;
            hierarchyTester.mainForm.Show();

            int[] nodeList1 =
            {
                0, 1, 1
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList1);

            // Create a new bank Account ...
            hierarchyTester.tbbAddNewAccount.Click();
            string newAccountName = hierarchyTester.txtDetailAccountCode.Properties.Text;

            hierarchyTester.chkDetailBankAccountFlag.Properties.Checked = true;
            Assert.IsTrue(hierarchyTester.tbbSave.Properties.Enabled, "Save button should be enabled");
            hierarchyTester.tbbSave.Click();
            hierarchyTester.mainForm.Close();

            // reopen the screen, check if the account is a bank account, and remove the bank account flag
            hierarchyTester = new TFrmGLAccountHierarchyTester();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;
            hierarchyTester.mainForm.Show();

            TreeNode[] nodes = hierarchyTester.trvAccounts.Properties.Nodes.Find(newAccountName, true);
            hierarchyTester.trvAccounts.Properties.SelectedNode = nodes[0];

            Assert.AreEqual(newAccountName, hierarchyTester.txtDetailAccountCode.Properties.Text, "we want to look at the newly created account");
            Assert.AreEqual(true, hierarchyTester.chkDetailBankAccountFlag.Checked, "this should have been stored as a bank account");
            hierarchyTester.chkDetailBankAccountFlag.Properties.Checked = false;
            hierarchyTester.tbbSave.Click();
            hierarchyTester.mainForm.Close();

            // reopen the screen, check if the account is not a bank account anymore
            hierarchyTester = new TFrmGLAccountHierarchyTester();
            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            nodes = hierarchyTester.trvAccounts.Properties.Nodes.Find(newAccountName, true);
            hierarchyTester.trvAccounts.Properties.SelectedNode = nodes[0];

            Assert.AreEqual(newAccountName,
                            hierarchyTester.txtDetailAccountCode.Properties.Text,
                            "we want to look at the newly created account, the second time");
            Assert.AreEqual(false, hierarchyTester.chkDetailBankAccountFlag.Checked, "this should have been stored not as a bank account");
            hierarchyTester.mainForm.Close();
        }
        public void T03_CreateANewAccount()
        {
            System.Console.WriteLine("-------T03_CreateANewAccount------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            int[] nodeList1 =
            {
                0, 1, 1
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList1);

            // Create a first Account ...
            hierarchyTester.tbbAddNewAccount.Click();
            String strName1 = hierarchyTester.txtDetailAccountCode.Properties.Text;

            // Enable tbbSave
            hierarchyTester.txtDetailEngAccountCodeLongDesc.Properties.Text = "x";
            hierarchyTester.tbbSave.Click();

            // Create a second Account ...
            hierarchyTester.trvAccounts.SelectNode(nodeList1);
            hierarchyTester.tbbAddNewAccount.Click();
            String strName2 = hierarchyTester.txtDetailAccountCode.Properties.Text;

            hierarchyTester.txtDetailEngAccountCodeLongDesc.Properties.Text = "y";
            hierarchyTester.tbbSave.Click();

            Assert.AreNotEqual(strName1, strName2, "Two Accounts must not have the same name");

            // Create a third Account ...
            hierarchyTester.trvAccounts.SelectNode(nodeList1);
            hierarchyTester.tbbAddNewAccount.Click();
            // String strName3 = hierarchyTester.txtDetailAccountCode.Properties.Text;
            hierarchyTester.txtDetailEngAccountCodeLongDesc.Properties.Text = "z";
            // use an invalid name
            hierarchyTester.txtDetailAccountCode.Properties.Text = strName1;

            WaitForMessageBox(MessageBoxTester.Command.Yes);
            hierarchyTester.tbbSave.Click();

            // Create a fourth Account ...
            hierarchyTester.trvAccounts.SelectNode(nodeList1);
            hierarchyTester.tbbAddNewAccount.Click();
            // String strName4 = hierarchyTester.txtDetailAccountCode.Properties.Text;
            hierarchyTester.txtDetailEngAccountCodeLongDesc.Properties.Text = "zz";
            // use an invalid name
            hierarchyTester.txtDetailAccountCode.Properties.Text = strName1;
        }
        public void T01_TreeViewFocusColor()
        {
            System.Console.WriteLine("-------T01_TreeViewFocusColor------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            // Focus on the TreeView ..
            hierarchyTester.trvAccounts.Properties.Focus();

            // Get a Node to operate ...
            int[] nodeList =
            {
                0, 2
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList);
            TreeNode node = hierarchyTester.trvAccounts.Properties.SelectedNode;

            // Colors form the node ...
            Color colorBackNode1 = node.BackColor;
            Color colorFontNode1 = node.ForeColor;

            // Focus to somewhere else
            hierarchyTester.txtDetailAccountCode.Properties.Focus();

            // Colors from the node
            Color colorBackNode2 = node.BackColor;
            Color colorFontNode2 = node.ForeColor;

            // Focus back to the treeview
            hierarchyTester.trvAccounts.Properties.Focus();

            // Colors from the node
            Color colorBackNode3 = node.BackColor;
            Color colorFontNode3 = node.ForeColor;

            // Different checks
            // 1. Colors 1&3 must be equal ...

            Assert.AreEqual(colorBackNode1, colorBackNode3, "Back-Color 1&3");
            Assert.AreEqual(colorFontNode1, colorFontNode3, "Font-Color 1&3");

            // 1. Colors 1&2 must be different ...
            Assert.AreNotEqual(colorBackNode1, colorBackNode2, "Back-Color 1&2");
            Assert.AreNotEqual(colorFontNode1, colorFontNode2, "Font-Color 1&2");
        }
        public void T02_SetAccountToForeigenCurrency()
        {
            System.Console.WriteLine("-------T02_SetAccountToForeigenCurrency------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            // Select a node ...
            int[] nodeList1 =
            {
                0, 0, 0, 0, 0
            };
            int[] nodeList2 =
            {
                0, 2
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList1);

            //TreeNode node = hierarchyTester.trvAccounts.Properties.SelectedNode;

            Boolean blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;

            Assert.AreEqual(blnSaveBtn, false, "Save button shall be not enabled!");

            String  str1;
            String  str2;
            Boolean blnCheckBoxSet;
            Boolean blnCheckBoxSet2;

            for (int i = 0; i <= 1; i++)
            {
                blnCheckBoxSet =
                    (hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState
                     == CheckState.Checked);

                if (blnCheckBoxSet)
                {
                    // Actually it is not possiblie to write SetSelectedString("ALL") ín order to
                    // reset a combobox. This is to be fixed with id 216
                    hierarchyTester.cmbDetailForeignCurrencyCode.Properties.SetSelectedString("ALL");
                    hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState =
                        CheckState.Unchecked;
                }
                else
                {
                    hierarchyTester.cmbDetailForeignCurrencyCode.Properties.SetSelectedString("CNY");
                    hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState =
                        CheckState.Checked;
                }

                blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;
                Assert.AreEqual(blnSaveBtn, true, "Save button must be enabled now!");
                hierarchyTester.tbbSave.Click();
                blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;
                Assert.AreEqual(blnSaveBtn, false, "Save button must be disabled again!");

                // Select an other node and switch back ...
                str1 = hierarchyTester.txtDetailAccountCode.Text;
                hierarchyTester.trvAccounts.SelectNode(nodeList2);
                str2 = hierarchyTester.txtDetailAccountCode.Text;
                Assert.AreNotEqual(str1, str2, "Value must change because node has changed");
                hierarchyTester.trvAccounts.SelectNode(nodeList1);
                str2 = hierarchyTester.txtDetailAccountCode.Text;
                Assert.AreEqual(str1, str2, "Value must be equal because node has changed back");

                // Get back the stored data ...
                blnCheckBoxSet2 =
                    (hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState
                     == CheckState.Checked);
                str1 = hierarchyTester.cmbDetailForeignCurrencyCode.Properties.GetSelectedString();

                if (blnCheckBoxSet)
                {
                    Assert.AreEqual("ALL", str1, "We shall find the stored data ...");
                    Assert.AreEqual(blnCheckBoxSet2, false, "Checkbox shall be unchecked now");
                }
                else
                {
                    Assert.AreEqual("CNY", str1, "We shall find the stored data ...");
                    Assert.AreEqual(blnCheckBoxSet2, true, "Checkbox shall be checked now");
                }
            }
        }
Exemplo n.º 6
0
        public void T02_SetAccountToForeignCurrency()
        {
            System.Console.WriteLine("-------T02_SetAccountToForeignCurrency------------");
            TFrmGLAccountHierarchyTester hierarchyTester
                = new TFrmGLAccountHierarchyTester();

            hierarchyTester.mainForm.Show();
            hierarchyTester.mainForm.LedgerNumber = fLedgerNumber;

            // Select a node ...
            int[] nodeList1 =
            {
                0, 0, 0, 0, 0
            };
            int[] nodeList2 =
            {
                0, 2
            };
            hierarchyTester.trvAccounts.SelectNode(nodeList1);

            //TreeNode node = hierarchyTester.trvAccounts.Properties.SelectedNode;

            Boolean blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;

            Assert.AreEqual(blnSaveBtn, false, "Save button shall be not enabled!");

            String  str1;
            String  str2;
            Boolean blnCheckBoxSet;
            Boolean blnCheckBoxSet2;

            // Problem: account 6000 is already fixed, ie. you cannot change it to a foreign currency account anymore.
            // TODO: create a new account, that can be changed to a foreign currency account.
            // or change another field, eg. the description, to check the save button
            Assert.IsTrue(hierarchyTester.chkDetailForeignCurrencyFlag.Properties.Enabled,
                          "the currency must be changeable for account " + hierarchyTester.txtDetailAccountCode.Text);

            for (int i = 0; i <= 1; i++)
            {
                blnCheckBoxSet =
                    (hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState
                     == CheckState.Checked);

                if (blnCheckBoxSet)
                {
                    hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState =
                        CheckState.Unchecked;
                }
                else
                {
                    hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState =
                        CheckState.Checked;
                    hierarchyTester.cmbDetailForeignCurrencyCode.Properties.SetSelectedString("CNY");
                    Assert.AreEqual("CNY", hierarchyTester.cmbDetailForeignCurrencyCode.Properties.GetSelectedString());
                }

                blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;
                Assert.AreEqual(blnSaveBtn, true, "Save button must be enabled now!");
                hierarchyTester.tbbSave.Click();
                blnSaveBtn = hierarchyTester.tbbSave.Properties.Enabled;
                Assert.AreEqual(blnSaveBtn, false, "Save button must be disabled again!");

                // Select an other node and switch back ...
                str1 = hierarchyTester.txtDetailAccountCode.Text;
                hierarchyTester.trvAccounts.SelectNode(nodeList2);
                str2 = hierarchyTester.txtDetailAccountCode.Text;
                Assert.AreNotEqual(str1, str2, "Value must change because node has changed");
                hierarchyTester.trvAccounts.SelectNode(nodeList1);
                str2 = hierarchyTester.txtDetailAccountCode.Text;
                Assert.AreEqual(str1, str2, "Value must be equal because node has changed back");

                // Get back the stored data ...
                blnCheckBoxSet2 =
                    (hierarchyTester.chkDetailForeignCurrencyFlag.Properties.CheckState
                     == CheckState.Checked);
                str1 = hierarchyTester.cmbDetailForeignCurrencyCode.Properties.GetSelectedString();

                if (blnCheckBoxSet)
                {
                    Assert.AreEqual("ALL", str1, "We shall find the stored data ...");
                    Assert.AreEqual(blnCheckBoxSet2, false, "Checkbox shall be unchecked now");
                }
                else
                {
                    Assert.AreEqual("CNY", str1, "We shall find the stored data ...");
                    Assert.AreEqual(blnCheckBoxSet2, true, "Checkbox shall be checked now");
                }
            }
        }