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. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; MockClass c = new MockClass(projectContent, "RootNamespace1.MyTestFixture1"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); // Add a second class with a different root namespace. c = new MockClass(projectContent, "RootNamespace2.MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(c); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); }
public void Init() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testClassesResultChanged = false; testClasses = new TestClassCollection(); // TestClass1. MockClass mockClass = new MockClass("TestClass1"); testClass1 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass1); // TestClass2. mockClass = new MockClass("TestClass2"); testClass2 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass2); // TestClass3. mockClass = new MockClass("TestClass3"); testClass3 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass3); testClasses.ResultChanged += TestClassesResultChanged; }
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() { 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 Init() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); MockClass mockClass = new MockClass("UnitTesting.Tests.MyTestFixture"); c = new TestClass(mockClass, testFrameworks); }
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() { 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. MockMethod 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); baseClass.Methods.Add(method); baseClass.Methods.Add(method); // Create test class. testClass = new TestClass(c, testFrameworks); }
public void Init() { solution = new Solution(new MockProjectChangeWatcher()); project1 = new MockCSharpProject(solution, "A"); ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project1); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project1, refProjectItem); solution.Folders.Add(project1); project2 = new MockCSharpProject(solution, "Z"); refProjectItem = new ReferenceProjectItem(project2); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project2, refProjectItem); solution.Folders.Add(project2); MockProjectContent projectContent = new MockProjectContent(); projectContent.Project = project1; testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); treeView = new DummyParserServiceTestTreeView(testFrameworks); treeView.ProjectContentForProject = projectContent; treeView.AddSolution(solution); projects = treeView.GetProjects(); }
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 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 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(); MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); MockMethod test1Method = new MockMethod(c, "Test1"); test1Method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test1Method); // Test 2 method is from a duplicate test class. MockMethod test2Method = new MockMethod(c, "Test2"); test2Method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test2Method); projectContent.Classes.Add(c); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); // Make sure test methods are created, otherwise // the Test2 method will never be looked at due to lazy evaluation // of test method. 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(projectContent, "RootNamespace.MyNewTestFixture"); newTestClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(newTestClass); newTestClass.Methods.Add(test2Method); newUnit.Classes.Add(newTestClass); testProject.UpdateParseInfo(oldUnit, newUnit); }
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(testClass.Class, "NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); testClass.Class.Methods.Add(testMethod); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); treeView = new DummyParserServiceTestTreeView(testFrameworks); 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() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); treeView = new DummyParserServiceTestTreeView(testFrameworks); treeView.ProjectContentForProject = new MockProjectContent(); project = new MockCSharpProject(); project.Name = "MyProject"; ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); refProjectItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, refProjectItem); treeView.AddProject(project); }
public void Init() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); projectContent = new MockProjectContent(); pad.ProjectContent = projectContent; solution = new Solution(new MockProjectChangeWatcher()); 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. 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; testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); testProject = new TestProject(project, projectContent, testFrameworks); }
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); }
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. MockClass 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 SetUp() { // Create solution. solution = new Solution(new MockProjectChangeWatcher()); // Create a project to display in the test tree view. 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; testClass = new MockClass(projectContent, "MyTestFixture"); testClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(testClass); 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]; // Expand the root node so any child nodes are // lazily created. rootNode.Expanding(); rootChildNodes = rootNode.Nodes; testFixtureNode = (ExtTreeNode)rootNode.Nodes[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 SetUp() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); treeView = new DummyParserServiceTestTreeView(testFrameworks); // Create a solution with two test projects. solution = new Solution(); // Create the first test project. firstProject = new MockCSharpProject(solution, "FirstTestProject"); ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(firstProject); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(firstProject, nunitFrameworkReferenceItem); // Create the second test project. secondProject = new MockCSharpProject(solution, "SecondTestProject"); nunitFrameworkReferenceItem = new ReferenceProjectItem(secondProject); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(secondProject, nunitFrameworkReferenceItem); // Add the projects to the solution. solution.Folders.Add(firstProject); solution.Folders.Add(secondProject); // Create a dummy project content so the projects will be added // to the tree. treeView.ProjectContentForProject = new MockProjectContent(); // Add the solution to the tree. treeView.AddSolution(solution); allTestsTreeNode = treeView.Nodes[0] as AllTestsTreeNode; firstTestProject = treeView.GetTestProject(firstProject); secondTestProject = treeView.GetTestProject(secondProject); }
public void SetUp() { // Create a project to display in the test tree view. project = new MockCSharpProject(); project.Name = "TestProject"; nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); List <IProject> projects = new List <IProject>(); projects.Add(project); // Add second non-test project. projects.Add(new MockCSharpProject()); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; testClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); testClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(testClass); // Add two methods to the test class only // one of which has test attributes. testMethod = new MockMethod(testClass, "NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); testClass.Methods.Add(testMethod); testClass.Methods.Add(new MockMethod(testClass)); // Add a second class that has no test fixture attribute. MockClass nonTestClass = new MockClass(projectContent); projectContent.Classes.Add(nonTestClass); testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. treeView = dummyTreeView as TestTreeView; treeView.AddProjects(projects); nodes = treeView.Nodes; rootNode = (ExtTreeNode)treeView.Nodes[0]; // Expand the root node so any child nodes are // lazily created. rootNode.Expanding(); rootChildNodes = rootNode.Nodes; rootNamespaceNode = (ExtTreeNode)rootNode.Nodes[0]; // Expand the first namespace node. rootNamespaceNode.Expanding(); rootNamespaceChildNodes = rootNamespaceNode.Nodes; testsNamespaceNode = (ExtTreeNode)rootNamespaceNode.Nodes[0]; // Expand the tests namespace node. testsNamespaceNode.Expanding(); testsNamespaceChildNodes = testsNamespaceNode.Nodes; testFixtureNode = (ExtTreeNode)testsNamespaceNode.Nodes[0]; // Expand the test node. testFixtureNode.Expanding(); testFixtureChildNodes = testFixtureNode.Nodes; testNode = (ExtTreeNode)testFixtureChildNodes[0]; }
public void Init() { testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); }