Esempio n. 1
0
        public TestLib(string name, int randomSeed)
        {
            global = new TestNamespace("Global");
            random = (randomSeed < 0) ? null : new System.Random(randomSeed);
            if (random != null)
            {
                System.Console.WriteLine("Test cases order is shuffled using seed: {0}", randomSeed);
            }

            var lib = System.Reflection.Assembly.LoadFile(name);

            System.Type[] classes = lib.GetTypes();
            System.Array.Sort(classes, CompareTypesByName);
            foreach (System.Type type in classes)
            {
                if (type.IsClass)
                {
                    var attrs = Reflection.GetAttributes(type, typeof(NUnit.Framework.TestFixtureAttribute), false);
                    if (attrs.Count() == 1)
                    {
                        global.Add(type.FullName, type, null);
                    }
                    else
                    {
                        foreach (var attr in attrs)
                        {
                            var arguments = Reflection.GetProperty(attr, "Arguments") as object[];
                            global.Add(type.FullName + "." + MethodHelper.GetDisplayName(type.GetConstructor(MethodHelper.GetArgumentTypes(arguments)), arguments), type, arguments);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 private void Run(string path, TestNamespace ns, TestCaseFilter filter, TestReporter reporter)
 {
     reporter.BeginSuite(ns);
     foreach (var item in GetItemOrder(ns.Items))
     {
         string itemPath = path;
         if (itemPath != "")
         {
             itemPath += '.';
         }
         itemPath += item.Name;
         if (filter.Match(itemPath))
         {
             if (item is TestNamespace)
             {
                 Run(itemPath, item as TestNamespace, filter, reporter);
             }
             if (item is TestFixtureClass)
             {
                 Run(itemPath, item as TestFixtureClass, filter, reporter);
             }
         }
     }
     reporter.EndSuite(ns, 0);
 }
Esempio n. 3
0
 static private void List(string indent, TestNamespace ns)
 {
     System.Console.WriteLine(indent + Label(ns));
     foreach (var item in ns.Items)
     {
         if (item is TestNamespace)
         {
             List(indent + "  ", item as TestNamespace);
         }
         if (item is TestFixtureClass)
         {
             List(indent + "  ", item as TestFixtureClass);
         }
     }
 }
Esempio n. 4
0
 private static string Label(TestNamespace ns)
 {
     return(string.Format("S{0}:[]{1}", ns.Id, ns.Name));
 }