Esempio n. 1
0
        void AddSampleData()
        {
            ContextMenu subMenu = window.MainMenu.OpenSubMenu("MenuHelp");

            subMenu.InvokeMenuItem("MenuSampleData");

            AutomationElement msgbox = window.FindChildWindow("Add Sample Data", 5);

            if (msgbox != null)
            {
                MessageBoxWrapper mbox = new MessageBoxWrapper(msgbox);
                mbox.ClickYes();
            }

            AutomationElement child = window.FindChildWindow("Sample Database Options", 10);

            if (child != null)
            {
                SampleDataDialogWrapper cd = new SampleDataDialogWrapper(child);
                cd.ClickOk();
            }

            Thread.Sleep(5000);
            window.WaitForInputIdle(5000);

            Save();

            sampleData = true;

            // give database time to flush...
            Thread.Sleep(2000);

            // now load the database and pull out the categories.
            MyMoney money = Load();

            List <string> categories = new List <string>();

            foreach (Category c in money.Categories)
            {
                string cat = c.GetFullName();
                categories.Add(cat);
            }
            categories.Sort();
            SampleCategories = categories.ToArray();


            List <string> payees = new List <string>();

            foreach (Payee p in money.Payees)
            {
                payees.Add(p.Name);
            }
            payees.Sort();
            SamplePayees = payees.ToArray();

            ClearTransactionViewState();
        }
Esempio n. 2
0
        void AddSampleData()
        {
            ContextMenu subMenu = window.MainMenu.OpenSubMenu("MenuHelp");

            subMenu.InvokeMenuItem("MenuSampleData");

            AutomationElement msgbox = window.Element.FindChildWindow("Add Sample Data", 5);

            if (msgbox != null)
            {
                MessageBoxWrapper mbox = new MessageBoxWrapper(msgbox);
                mbox.ClickYes();
            }

            AutomationElement child = window.Element.FindChildWindow("Sample Database Options", 10);

            if (child != null)
            {
                SampleDataDialogWrapper cd = new SampleDataDialogWrapper(child);
                cd.ClickOk();
            }

            Thread.Sleep(5000);
            window.WaitForInputIdle(5000);

            Save();

            window.WaitForInputIdle(5000);

            sampleData = true;

            // give database time to flush...
            Thread.Sleep(2000);
            int       retries = 5;
            MyMoney   money   = null;
            Exception ex      = null;

            while (retries > 0 && money == null)
            {
                // now load the database and pull out the categories.
                retries--;
                try
                {
                    money = Load();
                }
                catch (Exception e)
                {
                    // could be that the test process is still writing!
                    // so try again in a bit.
                    ex = e;
                    Thread.Sleep(1000);
                }
            }

            Assert.IsNotNull(money, "Could not load money database!");

            List <string> categories = new List <string>();

            foreach (Category c in money.Categories)
            {
                string cat = c.GetFullName();
                categories.Add(cat);
            }
            categories.Sort();
            SampleCategories = categories.ToArray();


            List <string> payees = new List <string>();

            foreach (Payee p in money.Payees)
            {
                payees.Add(p.Name);
            }
            payees.Sort();
            SamplePayees = payees.ToArray();

            ClearTransactionViewState();
        }