コード例 #1
0
ファイル: TestRunner.cs プロジェクト: tdhieu/openvss
        private void FindMethods(Type t, TestCollection tc)
        {
            // now get all the methods on the fixture
            MethodInfo[] methods = t.GetMethods(
                BindingFlags.Public | BindingFlags.NonPublic |
                BindingFlags.Instance);

            // if there is a fixture setup routine, invoke it
            foreach (MethodInfo mi in methods)
            {
                if (mi.IsPrivate) continue;

                object[] attr = mi.GetCustomAttributes(true);

                foreach (Attribute a in attr)
                {
                    if (a is TestFixtureSetUpAttribute)
                        tc.classSetup = mi;
                    else if (a is TestFixtureTearDownAttribute)
                        tc.classTeardown = mi;
                    else if (a is SetUpAttribute)
                        tc.setup = mi;
                    else if (a is TearDownAttribute)
                        tc.tearDown = mi;
                    else if (a is TestAttribute)
                    {
                        TestMethod tm = new TestMethod();
                        tm.member = mi;
                        tc.testMethods.Add(tm);
                    }
                }
            }
        }
コード例 #2
0
 public void EndFixture(TestCollection tc)
 {
     try
     {
         if (tc.classTeardown != null)
         {
             tc.classTeardown.Invoke(tc.fixture, null);
         }
     }
     catch (Exception ex)
     {
         tc.message = ex.Message;
         tc.stack   = ex.StackTrace;
         throw;
     }
 }
コード例 #3
0
        private void FindMethods(Type t, TestCollection tc)
        {
            // now get all the methods on the fixture
            MethodInfo[] methods = t.GetMethods(
                BindingFlags.Public | BindingFlags.NonPublic |
                BindingFlags.Instance);

            // if there is a fixture setup routine, invoke it
            foreach (MethodInfo mi in methods)
            {
                if (mi.IsPrivate)
                {
                    continue;
                }

                object[] attr = mi.GetCustomAttributes(true);

                foreach (Attribute a in attr)
                {
                    if (a is TestFixtureSetUpAttribute)
                    {
                        tc.classSetup = mi;
                    }
                    else if (a is TestFixtureTearDownAttribute)
                    {
                        tc.classTeardown = mi;
                    }
                    else if (a is SetUpAttribute)
                    {
                        tc.setup = mi;
                    }
                    else if (a is TearDownAttribute)
                    {
                        tc.tearDown = mi;
                    }
                    else if (a is TestAttribute)
                    {
                        TestMethod tm = new TestMethod();
                        tm.member = mi;
                        tc.testMethods.Add(tm);
                    }
                }
            }
        }
コード例 #4
0
        public void StartFixture(TestCollection tc)
        {
            try
            {
                if (tc.fixture == null)
                {
                    tc.fixture = Activator.CreateInstance(tc.fixtureType);
                }

                if (tc.classSetup != null)
                {
                    tc.classSetup.Invoke(tc.fixture, null);
                }
            }
            catch (Exception ex)
            {
                tc.message = ex.Message;
                tc.stack   = ex.StackTrace;
                throw;
            }
        }
コード例 #5
0
ファイル: TestRunner.cs プロジェクト: tdhieu/openvss
        public  ArrayList LoadTests()
        {
            Assembly me = Assembly.GetExecutingAssembly();

            Type[] types = me.GetTypes();

            foreach (Type t in types)
            {
                object[] o = t.GetCustomAttributes(typeof(TestFixtureAttribute), false);
                if (o == null || o.Length == 0) continue;

                TestCollection tc = new TestCollection();
                tc.name = t.Name;
                tc.fixtureType = t;

                FindMethods(t, tc);
                if (tc.testMethods.Count > 0)
                    tests.Add(tc);
            }
            return tests;
        }
コード例 #6
0
ファイル: TestRunner.cs プロジェクト: tdhieu/openvss
        public void StartFixture(TestCollection tc)
        {
            try
            {
                if (tc.fixture == null)
                    tc.fixture = Activator.CreateInstance(tc.fixtureType);

                if (tc.classSetup != null)
                    tc.classSetup.Invoke(tc.fixture, null);
            }
            catch (Exception ex)
            {
                tc.message = ex.Message;
                tc.stack = ex.StackTrace;
                throw;
            }
        }
コード例 #7
0
ファイル: TestRunner.cs プロジェクト: tdhieu/openvss
 public void EndFixture(TestCollection tc)
 {
     try
     {
         if (tc.classTeardown != null)
             tc.classTeardown.Invoke(tc.fixture, null);
     }
     catch (Exception ex)
     {
         tc.message = ex.Message;
         tc.stack = ex.StackTrace;
         throw;
     }
 }