Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Environments = EnvironmentProvider.GetEnvironments().OrderBy(a => a.ID).ToDictionary(a => a.ID);
            Systems      = SystemProvider.GetSystems().OrderBy(a => a.ID).ToDictionary(a => a.ID);
            Sites        = SiteProvider.GetSites().OrderBy(a => a.SystemID).ThenBy(a => a.Name).ToDictionary(a => a.ID);

            ltlError.Text = string.Empty;

            if (!IsPostBack)
            {
                Init();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets up the form
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //setup for testing
            CoreExtensions.Host.InitializeService();
            //get the test suite
            TestSuite suite = TestUtility.GetTestSuite(Constants.DefaultWebTestAssembly);

            //get dictionaries for forms and querying
            foreach (TestMethod tm in suite.GetMethods())
            {
                Methods.Add(tm.TestName.FullName, tm);
            }
            foreach (TestFixture tf in suite.GetFixtures())
            {
                Fixtures.Add(tf.ClassName, tf);
            }
            foreach (TestEnvironment t in EnvironmentProvider.GetEnvironments().OrderBy(a => a.Name))
            {
                Environments.Add(t.ID, t);
            }
            foreach (TestSystem tsys in SystemProvider.GetSystems().OrderBy(a => a.Name))
            {
                Systems.Add(tsys.ID, tsys);
            }
            foreach (TestSite ts in SiteProvider.GetEnabledSites().OrderBy(a => a.SystemID).ThenBy(a => a.Name))
            {
                try {
                    Sites.Add(ts.ID, ts);
                } catch (ArgumentException aex) {
                    throw new ArgumentException(string.Format("This key has already been added: {0}-{1}", ts.SystemID, ts.Name));
                }
            }

            ltlResults.Text = string.Empty;             //reset output
            ltlError.Text   = string.Empty;
            ltlLog.Text     = string.Empty;

            if (!IsPostBack)               //setup form
            {
                foreach (KeyValuePair <string, TestFixture> kvp in Fixtures)
                {
                    ListItem li = new ListItem(TestUtility.GetClassName(kvp.Value.ClassName), kvp.Value.TestName.FullName);
                    cblTests.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestEnvironment> ekvp in Environments)
                {
                    ListItem li = new ListItem(ekvp.Value.Name, ekvp.Key.ToString());
                    cblEnv.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSystem> sykvp in Systems)
                {
                    ListItem li = new ListItem(sykvp.Value.Name, sykvp.Value.Name);
                    cblSystems.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSite> skvp in Sites)
                {
                    ListItem li = new ListItem(string.Format("{1}<span class='systemName'>{0}</span>", Systems[skvp.Value.SystemID].Name, skvp.Value.Name), skvp.Key.ToString());
                    li.Attributes.Add("class", Systems[skvp.Value.SystemID].Name);
                    cblSites.Items.Add(li);
                }
            }
            else
            {
                foreach (ListItem li in cblSites.Items)                   //css classes get lost on postback
                {
                    li.Attributes.Add("class", Systems[Sites[int.Parse(li.Value)].SystemID].Name);
                }
            }
        }
Exemplo n.º 3
0
        static void RunWebTest(string[] args)
        {
            //params 1 = test assembly
            string testAssembly = string.Empty;

            if (args.Length > 1)
            {
                testAssembly = args[1];
            }
            else
            {
                Console.WriteLine("You need to specify an assembly.");
                return;
            }

            //params 2 = test name
            string testName = string.Empty;

            if (args.Length > 2)
            {
                testName = args[2];
            }
            else
            {
                Console.WriteLine("You need to specify a test.");
                return;
            }

            //params 3 = environments
            Dictionary <int, TestEnvironment> Environments = new Dictionary <int, TestEnvironment>();

            if (args.Length > 3)
            {
                IEnumerable <TestEnvironment> prEnv = EnvironmentProvider.GetEnvironments();
                foreach (string s in GetStrings(args[3]))
                {
                    foreach (TestEnvironment fenv in prEnv.Where(a => a.ID.Equals(int.Parse(s))))
                    {
                        if (!Environments.ContainsKey(fenv.ID))
                        {
                            Console.WriteLine(string.Format("Adding '{0}' Environment.", fenv.Name));
                            Environments.Add(fenv.ID, fenv);
                        }
                    }
                }
            }

            // params 4 = systems
            // params 5 = sites
            // will look for sites by system unless systems is an empty string then it looks for them by site
            Dictionary <int, TestSite> Sites   = new Dictionary <int, TestSite>();
            IEnumerable <TestSite>     prSites = SiteProvider.GetEnabledSites();

            if (args.Length > 4 && !string.IsNullOrEmpty(args[4]))
            {
                foreach (string s in GetStrings(args[4]))
                {
                    foreach (TestSite fsite in prSites.Where(a => a.SystemID.Equals(int.Parse(s))))
                    {
                        if (!Sites.ContainsKey(fsite.ID))
                        {
                            Console.WriteLine(string.Format("Adding '{0}' Site.", fsite.Name));
                            Sites.Add(fsite.ID, fsite);
                        }
                    }
                }
            }
            if (args.Length > 5)
            {
                foreach (string s in GetStrings(args[5]))
                {
                    foreach (TestSite fsite in prSites.Where(a => a.ID.Equals(int.Parse(s))))
                    {
                        if (!Sites.ContainsKey(fsite.ID))
                        {
                            Console.WriteLine(string.Format("Adding '{0}' Site.", fsite.Name));
                            Sites.Add(fsite.ID, fsite);
                        }
                    }
                }
            }

            //setup for testing
            CoreExtensions.Host.InitializeService();
            //get the test suite
            TestSuite suite = TestUtility.GetTestSuite(testAssembly);

            IEnumerable <TestFixture> Fixtures = suite.GetFixtures().Where(a => a.ClassName.EndsWith(string.Format(".{0}", testName)));

            if (!Fixtures.Any())
            {
                Console.WriteLine("There were no Test Fixtures found. Make sure the class has the [TestFixture] attribute.");
                return;
            }
            TestFixture    tf      = Fixtures.First();
            WebTestManager manager = new WebTestManager(new WebConsoleTestHandler());

            manager.RunTest(tf, Environments.Values, Sites.Values);
        }