1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
4
using ICSharpCode.SharpDevelop.Dom;
5
using ICSharpCode.SharpDevelop.Project;
6
using ICSharpCode.UnitTesting;
9
using UnitTesting.Tests.Utils;
11
namespace UnitTesting.Tests.Project
14
public class TwoRootNamespacesTestFixture
16
TestProject testProject;
17
MockProjectContent projectContent;
18
MockTestFrameworksWithNUnitFrameworkSupport testFrameworks;
23
// Create a project to display in the test tree view.
24
IProject project = new MockCSharpProject();
25
project.Name = "TestProject";
26
ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);
27
nunitFrameworkReferenceItem.Include = "NUnit.Framework";
28
ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
30
// Add a test class with a TestFixture attributes.
31
projectContent = new MockProjectContent();
32
projectContent.Language = LanguageProperties.None;
33
MockClass c = new MockClass(projectContent, "RootNamespace1.MyTestFixture1");
34
c.Attributes.Add(new MockAttribute("TestFixture"));
35
projectContent.Classes.Add(c);
37
// Add a second class with a different root namespace.
38
c = new MockClass(projectContent, "RootNamespace2.MyTestFixture2");
39
c.Attributes.Add(new MockAttribute("TestFixture"));
40
projectContent.Classes.Add(c);
42
testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
43
testProject = new TestProject(project, projectContent, testFrameworks);
47
public void TwoRootNamespaces()
49
Assert.AreEqual(2, testProject.RootNamespaces.Count);
53
public void RootNamespace1()
55
Assert.AreEqual("RootNamespace1", testProject.RootNamespaces[0]);
59
public void RootNamespace2()
61
Assert.AreEqual("RootNamespace2", testProject.RootNamespaces[1]);
65
public void OneClassInNamespace1()
67
Assert.AreEqual(1, testProject.GetTestClasses("RootNamespace1").Length);
71
public void ClassNameInNamespace1()
73
TestClass[] classes = testProject.GetTestClasses("RootNamespace1");
74
Assert.AreEqual("MyTestFixture1", classes[0].Name);
78
public void OneClassInNamespace2()
80
Assert.AreEqual(1, testProject.GetTestClasses("RootNamespace2").Length);
84
public void ClassNameInNamespace2()
86
TestClass[] classes = testProject.GetTestClasses("RootNamespace2");
87
Assert.AreEqual("MyTestFixture2", classes[0].Name);
91
public void TwoClassesStartWithRootNamespace()
93
TestClass[] classes = testProject.GetAllTestClasses("RootNamespace");
94
Assert.AreEqual(2, classes.Length);
95
Assert.AreEqual("MyTestFixture1", classes[0].Name);
96
Assert.AreEqual("MyTestFixture2", classes[1].Name);
100
public void NoChildNamespaces()
102
Assert.AreEqual(0, testProject.GetChildNamespaces("RootNamespace").Length);
106
public void TwoChildNamespacesForEmptyNamespace()
108
string[] namespaces = testProject.GetChildNamespaces(String.Empty);
109
Assert.AreEqual(2, namespaces.Length);
110
Assert.AreEqual("RootNamespace1", namespaces[0]);
111
Assert.AreEqual("RootNamespace2", namespaces[1]);
115
/// Makes sure that the fully qualified class name is used
116
/// when working out the overall test result in the
117
/// TestClassCollection.
120
public void DuplicateClassName()
122
MockClass c = new MockClass(projectContent, "RootNamespace1.MyTestFixture2");
123
c.Attributes.Add(new MockAttribute("TestFixture"));
125
TestClass testClass = new TestClass(c, testFrameworks);
126
testProject.TestClasses.Add(testClass);
128
testClass.Result = TestResultType.Failure;
129
TestClass testClass2 = testProject.TestClasses["RootNamespace2.MyTestFixture2"];
130
testClass2.Result = TestResultType.Failure;
132
Assert.AreEqual(TestResultType.Failure, testProject.TestClasses.Result);