Example #1
0
        public void RunTest(TestFixture tf, IEnumerable <TestEnvironment> Environments, IEnumerable <TestSite> Sites)
        {
            if (tf == null)
            {
                throw new NullReferenceException("Test Fixture was null. Make sure the class has the [TestFixture] attribute.");
            }
            TestMethod tm = tf.GetMethod("RunTest");

            if (tm == null)
            {
                throw new NullReferenceException("Test Method was null. Make sure the class method has the [Test] attribute.");
            }
            foreach (TestEnvironment te in Environments)
            {
                foreach (TestSite ts in Sites)
                {
                    if (!ts.Environments.Any(en => en.ID.Equals(te.ID)))
                    {
                        Handler.OnSkipped(tm, te, ts);
                        continue;
                    }

                    //set properties to be used during testing
                    tm.SetProperty(BaseWebTest.RequestURLKey, ts.BaseURL(te));
                    tm.SetProperty(BaseWebTest.EnvironmentKey, te);
                    tm.SetProperty(BaseWebTest.SiteKey, ts);

                    var t = new Thread(new ThreadStart(() => HandleTest(tf, tm, te, ts)));
                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();
                    t.Join();
                }
            }
        }