public void Init() { resultChangedCalled = false; classesAdded = new List<TestClass>(); classesRemoved = new List<TestClass>(); // Create a project. project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.SetCompoundClass(c); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Add a second class that has no test fixture attribute. MockClass nonTestClass = new MockClass(projectContent); projectContent.Classes.Add(nonTestClass); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); testProject.TestClasses.TestClassAdded += TestClassAdded; testProject.TestClasses.TestClassRemoved += TestClassRemoved; testClass = testProject.TestClasses[0]; }
public void SetUp() { solution = new Solution(); // Create a project to display in the test tree view. project = new MockCSharpProject(solution, "TestProject"); ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; testClass1 = new MockClass(projectContent, "Project.Tests.MyTestFixture"); testClass1.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(testClass1); testClass2 = new MockClass(projectContent, "Project.MyTestFixture"); testClass2.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(testClass2); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. treeView = dummyTreeView as TestTreeView; solution.Folders.Add(project); treeView.AddSolution(solution); nodes = treeView.Nodes; rootNode = (ExtTreeNode)treeView.Nodes[0]; treeView.SelectedNode = rootNode; testProject = treeView.SelectedTestProject; }
public void Init() { // Create a project to display. project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass("RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class with the same name. MockClass secondTestClass = new MockClass("RootNamespace.MyTestFixture"); secondTestClass.ProjectContent = projectContent; secondTestClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(secondTestClass); testProject = new TestProject(project, projectContent); }
public void Init() { // Create a project to display in the test tree view. IProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class with a TestFixture attributes. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass("RootNamespace.MyTestFixture"); c.Namespace = "RootNamespace"; c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class no root namespace. c = new MockClass("MyTestFixture2"); c.Namespace = String.Empty; c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); testProject = new TestProject(project, projectContent); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); // Create the base test class. MockClass baseClass = new MockClass(projectContent, "RootNamespace.TestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); MockMethod baseMethod = new MockMethod(baseClass, "BaseMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); MockMethod method = new MockMethod(c, "DerivedMethod"); method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(method); projectContent.Classes.Add(c); // Set derived class's base class. c.AddBaseClass(baseClass); // Create TestClass. testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testClass = new TestClass(c, testFrameworks); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests"); baseClass.ProjectContent = projectContent; MockMethod baseMethod = new MockMethod("InheritanceTests"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); // Add a second method that does not have a Test attribute. baseMethod = new MockMethod("NonTestMethod"); baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass("ICSharpCode.SharpDevelop.Tests.CecilLayerTests"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Set derived class's base class. c.BaseClass = baseClass; // Create TestClass. testClass = new TestClass(c); }
public void Init() { IProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(mockClass); // Add a method to the test class MockMethod mockMethod = new MockMethod(mockClass, "TestMethod1"); mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); mockMethod = new MockMethod(mockClass, "TestMethod2"); mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); testClass = testProject.TestClasses[0]; testMethod1 = testClass.TestMembers[0]; testMethod2 = testClass.TestMembers[1]; }
public void Init() { solution = new Solution(); project1 = new MockCSharpProject(solution); project1.Name = "A"; ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project1); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project1, refProjectItem); solution.Folders.Add(project1); project2 = new MockCSharpProject(solution); project2.Name = "Z"; refProjectItem = new ReferenceProjectItem(project2); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project2, refProjectItem); solution.Folders.Add(project2); MockProjectContent projectContent = new MockProjectContent(); projectContent.Project = project1; treeView = new DummyParserServiceTestTreeView(); treeView.ProjectContentForProject = projectContent; treeView.AddSolution(solution); projects = treeView.GetProjects(); }
protected void InitBase() { projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. outerClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(outerClass); // Create the inner test class. // Note the use of the DotNetName "MyTests.A+InnerTest". innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); innerClass.Attributes.Add(new MockAttribute("TestFixture")); MockMethod method = new MockMethod(innerClass, "FooBar"); method.Attributes.Add(new MockAttribute("Test")); innerClass.Methods.Add(method); outerClass.InnerClasses.Add(innerClass); // Add another inner class that is not a test class. nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass); outerClass.InnerClasses.Add(nonTestInnerClass); // Add another inner class with the same name as the InnerATest. // This makes sure duplicate classes are not added. MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture")); outerClass.InnerClasses.Add(duplicateInnerClass); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(null, projectContent, testFrameworks); if (testProject.TestClasses.Count > 0) { testClass = testProject.TestClasses[0]; } }
public void Init() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); // Add a test class. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Add first method. var method = new MockMethod(c, "MyTest"); method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(method); // Add duplicate method. c.Methods.Add(method); // Add a base class that has duplicate methods. MockClass baseClass = new MockClass(projectContent, "RootNamespace.MyTestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(baseClass); c.AddBaseClass(baseClass); var baseClassMethod = new MockMethod(baseClass, "MyTest"); baseClassMethod.Attributes.Add(new MockAttribute("Test")); baseClass.Methods.Add(baseClassMethod); baseClass.Methods.Add(baseClassMethod); // Create test class. testClass = new TestClass(c, testFrameworks); }
public void Init() { resultChangedCalled = false; IProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); mockClass.Namespace = "RootNamespace.Tests"; mockClass.ProjectContent = projectContent; mockClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(mockClass); // Add a method to the test class MockMethod mockMethod = new MockMethod("TestMethod"); mockMethod.DeclaringType = mockClass; mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); testProject = new TestProject(project, projectContent); testClass = testProject.TestClasses[0]; testMethod = testClass.TestMethods[0]; }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the top base test class. MockClass baseBaseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); baseBaseClass.ProjectContent = projectContent; MockMethod baseMethod = new MockMethod("BaseBaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseBaseClass; baseBaseClass.Methods.Add(baseMethod); // Create the next level test class. MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); baseClass.ProjectContent = projectContent; baseMethod = new MockMethod("BaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass("ICSharpCode.SharpDevelop.Tests.MainTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Set the base class for each class in the hierarchy. c.BaseClass = baseClass; baseClass.BaseClass = baseBaseClass; // Create TestClass. testClass = new TestClass(c); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the top base test class. MockClass baseBaseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); MockMethod baseMethod = new MockMethod(baseBaseClass, "BaseBaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseBaseClass.Methods.Add(baseMethod); // Create the next level test class. MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); baseMethod = new MockMethod(baseClass, "BaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.MainTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Set the base class for each class in the hierarchy. c.AddBaseClass(baseClass); baseClass.AddBaseClass(baseBaseClass); // Create TestClass. testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testClass = new TestClass(c, testFrameworks); }
public void Init() { // Add a test class. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass("RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add first method. MockMethod method = new MockMethod("MyTest"); method.Attributes.Add(new MockAttribute("Test")); method.DeclaringType = c; c.Methods.Add(method); // Add duplicate method. c.Methods.Add(method); // Add a base class that has duplicate methods. MockClass baseClass = new MockClass("RootNamespace.MyTestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); baseClass.ProjectContent = projectContent; projectContent.Classes.Add(baseClass); c.BaseClass = baseClass; baseClass.Methods.Add(method); baseClass.Methods.Add(method); // Create test class. testClass = new TestClass(c); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); // Create the base test class. MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests"); MockMethod baseMethod = new MockMethod(baseClass, "InheritanceTests"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseClass.Methods.Add(baseMethod); // Add a second method that does not have a Test attribute. baseMethod = new MockMethod(baseClass, "NonTestMethod"); baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.CecilLayerTests"); c.SetDotNetName(c.FullyQualifiedName); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Set derived class's base class. c.AddBaseClass(baseClass); // Create TestClass. MockTestFrameworksWithNUnitFrameworkSupport testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testClass = new TestClass(c, testFrameworks); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. MockClass baseClass = new MockClass("RootNamespace.TestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); baseClass.ProjectContent = projectContent; MockMethod baseMethod = new MockMethod("BaseMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass("RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; MockMethod method = new MockMethod("DerivedMethod"); method.DeclaringType = c; method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(method); projectContent.Classes.Add(c); // Set derived class's base class. c.BaseClass = baseClass; // Create TestClass. testClass = new TestClass(c); }
public void IsTestClassReturnsFalseWhenProjectContentLanguageIsNull() { IProject project = new MockCSharpProject(); MockProjectContent mockProjectContent = new MockProjectContent(); mockProjectContent.Project = project; MockClass mockClass = new MockClass(mockProjectContent); Assert.IsFalse(testFramework.IsTestClass(mockClass)); }
public void NullLanguage() { IProject project = new MockCSharpProject(); MockClass mockClass = new MockClass(); MockProjectContent mockProjectContent = new MockProjectContent(); mockProjectContent.Project = project; mockClass.ProjectContent = mockProjectContent; Assert.IsFalse(TestClass.IsTestClass(mockClass)); }
public void IsTestClassReturnsFalseWhenProjectContentLanguageNameComparerIsNull() { IProject project = new MockCSharpProject(); MockProjectContent mockProjectContent = new MockProjectContent(); mockProjectContent.Project = project; mockProjectContent.Language = new LanguageProperties(null); MockClass mockClass = new MockClass(mockProjectContent); mockClass.Attributes.Add(new MockAttribute("Test")); Assert.IsFalse(testFramework.IsTestClass(mockClass)); }
public void Init() { // Create a project to display. project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass("RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; c.SetCompoundClass(c); MockMethod test1Method = new MockMethod("Test1"); test1Method .DeclaringType = c; test1Method .Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test1Method); // Test 2 method is from a duplicate test class. MockMethod test2Method = new MockMethod("Test2"); test2Method.DeclaringType = c; test2Method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test2Method); projectContent.Classes.Add(c); testProject = new TestProject(project, projectContent); // Make sure test methods are created, otherwise // the Test2 method will never be looked at due to lazy evaluation // of test method.s int count = testProject.TestClasses[0].TestMethods.Count; // Change the name of the second test class. DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(c); c.Methods.Remove(test2Method); // Remove duplicate test class method. // Create new compilation unit with inner class that has its method renamed. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); MockClass newTestClass = new MockClass("RootNamespace.MyNewTestFixture"); newTestClass.ProjectContent = projectContent; newTestClass.Attributes.Add(new MockAttribute("TestFixture")); newTestClass.SetCompoundClass(newTestClass); projectContent.Classes.Add(newTestClass); newTestClass.Methods.Add(test2Method); newUnit.Classes.Add(newTestClass); testProject.UpdateParseInfo(oldUnit, newUnit); }
public void NullNameComparer() { IProject project = new MockCSharpProject(); MockClass mockClass = new MockClass(); MockProjectContent mockProjectContent = new MockProjectContent(); mockProjectContent.Project = project; mockProjectContent.Language = new LanguageProperties(null); mockClass.ProjectContent = mockProjectContent; mockClass.Attributes.Add(new MockAttribute("Test")); Assert.IsFalse(TestClass.IsTestClass(mockClass)); }
public void SetUp() { Solution solution = new Solution(); MockCSharpProject project = new MockCSharpProject(); MockProjectContent projectContent = new MockProjectContent(); projectContent.Project = project; projectContent.Language = LanguageProperties.None; ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, refProjectItem); solution.Folders.Add(project); pad = new DerivedUnitTestsPad(solution); }
public void NullNameComparer() { IProject project = new MockCSharpProject(); MockClass mockClass = new MockClass(); MockProjectContent mockProjectContent = new MockProjectContent(); mockProjectContent.Project = project; mockProjectContent.Language = new LanguageProperties(null); mockClass.ProjectContent = mockProjectContent; MockMethod mockMethod = new MockMethod(); mockMethod.DeclaringType = mockClass; mockMethod.Attributes.Add(new MockAttribute("Test")); Assert.IsFalse(TestMethod.IsTestMethod(mockMethod)); }
public void Init() { // Create a project to display. IProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; testProject = new TestProject(project, projectContent); }
public void Init() { projectContent = new MockProjectContent(); pad.ProjectContent = projectContent; solution = new Solution(); project = new MockCSharpProject(); projectContent.Project = project; projectContent.Language = LanguageProperties.None; ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, refProjectItem); solution.Folders.Add(project); pad.CallSolutionLoaded(solution); }
public void Init() { // Create a project to display in the test tree view. MockCSharpProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); List<IProject> projects = new List<IProject>(); projects.Add(project); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; TestClass testClass = CreateTestClass("MyTests.MyTestFixture"); projectContent.Classes.Add(testClass.Class); // Add two methods to the test class only // one of which has test attributes. MockMethod testMethod = new MockMethod("NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); testMethod.DeclaringType = testClass.Class; testClass.Class.Methods.Add(testMethod); // Init mock project content to be returned. treeView = new DummyParserServiceTestTreeView(); treeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. treeView.AddProjects(projects); projectNode = (TestProjectTreeNode)treeView.Nodes[0]; testProject = projectNode.TestProject; // Initialise the root node so the child nodes are created. projectNode.PerformInitialization(); myTestsNamespaceNode = (TestNamespaceTreeNode)projectNode.FirstNode; // Initialise the first namespace node. myTestsNamespaceNode.PerformInitialization(); testFixtureNode = (TestClassTreeNode)myTestsNamespaceNode.FirstNode; // Initialise the test method tree nodes. testFixtureNode.PerformInitialization(); }
public void Init() { solution = new Solution(); testProject = new MockCSharpProject(solution, "A"); solution.Folders.Add(testProject); nonTestProject = new MockCSharpProject(solution, "Z"); solution.Folders.Add(nonTestProject); MockProjectContent projectContent = new MockProjectContent(); testFrameworks = new MockRegisteredTestFrameworks(); testFrameworks.AddTestProject(testProject); treeView = new DummyParserServiceTestTreeView(testFrameworks); treeView.ProjectContentForProject = projectContent; treeView.AddSolution(solution); projects = treeView.GetProjects(); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. MockClass baseClass = new MockClass("ICSharpCode.Tests.BaseClass"); baseClass.ProjectContent = projectContent; // Add a virtual method to base class. MockMethod baseMethod = new MockMethod("VirtualTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseClass; baseMethod.IsVirtual = true; baseClass.Methods.Add(baseMethod); // Add a second method that is virtual but will not be overriden. baseMethod = new MockMethod("VirtualNonOverriddenTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.DeclaringType = baseClass; baseMethod.IsVirtual = true; baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass("ICSharpCode.Tests.DerivedClass"); c.Attributes.Add(new MockAttribute("TestFixture")); c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Create a new test method that overrides one of the base class methods. MockMethod method = new MockMethod("VirtualTestMethod"); method.Attributes.Add(new MockAttribute("Test")); method.DeclaringType = c; method.IsOverride = true; c.Methods.Add(method); // Set derived class's base class. c.BaseClass = baseClass; // Create TestClass. testClass = new TestClass(c); }
public void SetUp() { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. MockClass baseClass = new MockClass(projectContent, "ICSharpCode.Tests.BaseClass"); // Add a virtual method to base class. MockMethod baseMethod = new MockMethod(baseClass, "VirtualTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.Modifiers = ModifierEnum.Virtual; baseClass.Methods.Add(baseMethod); // Add a second method that is virtual but will not be overriden. baseMethod = new MockMethod(baseClass, "VirtualNonOverriddenTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); baseMethod.Modifiers = ModifierEnum.Virtual; baseClass.Methods.Add(baseMethod); // Create the derived test class. c = new MockClass(projectContent, "ICSharpCode.Tests.DerivedClass"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Create a new test method that overrides one of the base class methods. MockMethod method = new MockMethod(c, "VirtualTestMethod"); method.Attributes.Add(new MockAttribute("Test")); method.Modifiers = ModifierEnum.Override; c.Methods.Add(method); // Set derived class's base class. c.AddBaseClass(baseClass); // Create TestClass. testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testClass = new TestClass(c, testFrameworks); }
public void Init() { // Create a project. IProject project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class with a TestFixture attributes. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Add a second class the same root namespace. c = new MockClass(projectContent, "RootNamespace.MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); }