示例#1
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Specify test assembly is parameter");
                return;
            }

            var location = args.First();
            var ai = new AssemblyInspector(location);
            var classes = ai.GetClasses();
            int apassed = 0, afailed = 0;

            foreach (var c in classes)
            {
                var runner = new TestRunner(c);
                Console.WriteLine(c.Name);

                var ci = new ClassInspector(c);

                if (!ExecuteIfExists(runner, ci.GetClassInitialize()))
                {
                    break;
                }

                var testinit = ci.GetTestInitialize();
                var testclean = ci.GetTestCleanUp();
                var methods = ci.GetMethods();
                int cpassed = 0, cfailed = 0;

                foreach (var m in methods)
                {
                    if (!ExecuteIfExists(runner, testinit))
                    {
                        break;
                    }

                    ExecuteTest(ref apassed, ref afailed, runner, ref cpassed, ref cfailed, m);
                    ExecuteIfExists(runner, testclean);
                }

                ExecuteIfExists(runner, ci.GetClassCleanUp());
                Console.WriteLine("  [{0}] Tests passed: {1}, tests failed: {2}", c.Name, cpassed, cfailed);
            }
            Console.WriteLine("Tests passed: {0}, tests failed: {1}", apassed, afailed);
        }
示例#2
0
        public void TestListAllClassesOfTestAssembly()
        {
            var inspector = new AssemblyInspector(this.GetType().Assembly.Location);
            var classes = inspector.GetClasses();

            Assert.IsTrue(classes.Any(c => c == this.GetType()));
        }
示例#3
0
        public void OnlyListTestClassesOfTestAssembly()
        {
            var inspector = new AssemblyInspector(this.GetType().Assembly.Location);
            var classes = inspector.GetClasses();

            Assert.IsFalse(classes.Any(c => c == typeof(NormalClass)));
        }