Esempio n. 1
0
        public void Add(string path, System.Type type, object[] arguments)
        {
            int index = path.IndexOf('.');

            if (index < 0)
            {
                Items.Add(new TestFixtureClass(path, type, arguments));
                return;
            }

            string        name = path.Substring(0, index);
            string        tail = path.Substring(index + 1);
            TestNamespace ns   = Items.Find(item => item.Name == name) as TestNamespace;

            if (ns != null)
            {
                ns.Add(tail, type, arguments);
                return;
            }

            TestNamespace newNs = new TestNamespace(name);

            newNs.Add(tail, type, arguments);
            Items.Add(newNs);
        }
Esempio n. 2
0
        public void TestNamespaceSpecifiedInInitialize()
        {
            var testNamespace           = new TestNamespace(testProject, "Project.MyTests");
            NUnitConsoleApplication app = new NUnitConsoleApplication(new[] { testNamespace });

            app.NoLogo          = false;
            app.ShadowCopy      = true;
            app.NoXmlOutputFile = false;

            string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\"";

            Assert.AreEqual(expectedCommandLine, app.GetArguments());
        }
        public static TestSuite GroupByNamespace(TestSuite testSuite)
        {
            if (testSuite == null)
                return null;

            var result = new TestSuite(testSuite.Name + ".Application");

            foreach (var testGroup in testSuite.Tests.GroupBy(x => GetNamespace(x)))
            {
                var namespaceSuite = new TestNamespace(testGroup.Key);
                foreach (var test in testGroup)
                {
                    namespaceSuite.Tests.Add(test);
                }

                result.Tests.Add(namespaceSuite);
            }

            return result;
        }
Esempio n. 4
0
    public void TestFn2(TestNamespace.ClassAsValueType v)
    {

    }
Esempio n. 5
0
    public void TestFn1(TestNamespace.Float2 v)
    {

    }
Esempio n. 6
0
        private static TestItem AddTestItem(Dictionary <string, TestItem> items, CodeItemKind itemKind, string itemPath, TestCase testCase = null, string displayName = null, string testAdapterName = null)
        {
            var nameParts  = itemPath.SplitPath();
            var parentName = string.Join(string.Empty, nameParts.Take(nameParts.Length - 1));
            var itemName   = nameParts[nameParts.Length - 1];

            TestItem parent;

            if (!items.TryGetValue(parentName, out parent))
            {
                switch (itemKind)
                {
                case CodeItemKind.Data:
                    parent = AddTestItem(items, CodeItemKind.Method, parentName);
                    break;

                case CodeItemKind.Class:
                    if (itemName.StartsWith("+"))
                    {
                        parent = AddTestItem(items, CodeItemKind.Class, parentName);
                    }
                    else
                    {
                        parent = AddTestItem(items, CodeItemKind.Namespace, parentName);
                    }
                    break;

                case CodeItemKind.Method:
                    parent = AddTestItem(items, CodeItemKind.Class, parentName);
                    break;

                default:
                    parent = AddTestItem(items, CodeItemKind.Namespace, parentName);
                    break;
                }
            }

            var      name = itemName.TrimStart('.', '+');
            TestItem item = null;

            switch (itemKind)
            {
            case CodeItemKind.Namespace:
                item = new TestNamespace(parent as TestNamespace, name);
                break;

            case CodeItemKind.Class:
                if (parent is TestClass)
                {
                    item = new TestClass(parent as TestClass, name);
                }
                else
                {
                    item = new TestClass(parent as TestNamespace, name);
                }
                break;

            case CodeItemKind.Method:
                item = new TestMethod(parent as TestClass, name, testCase, testAdapterName);
                break;

            case CodeItemKind.Data:
                item = new TestMethod(parent as TestMethod, name, displayName, testCase, testAdapterName);
                break;

            default:
                throw new NotImplementedException();
            }
            items.Add(itemPath, item);

            return(item);
        }
Esempio n. 7
0
 public TestClass(TestNamespace parent, string name)
     : base(parent, name, CodeItemKind.Class)
 {
 }
Esempio n. 8
0
 static void Main(string[] args)
 {
     TestNamespace.PrintTest();
     Console.ReadKey();
 }
Esempio n. 9
0
 protected TestNamespace(TestNamespace parent, string name, CodeItemKind kind)
     : base(parent, name, kind)
 {
 }
Esempio n. 10
0
 public TestNamespace(TestNamespace parent, string name)
     : base(parent, name, CodeItemKind.Namespace)
 {
 }