コード例 #1
2
		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];
		}
コード例 #2
0
		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()
		{
			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;
		}
コード例 #4
0
		public void Init()
		{
			base.InitBase();
			
			project1 = new MockCSharpProject();
			testProject1 = 
				TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass1", "testMethod1");
			
			project2 = new MockCSharpProject();
			testProject2 = 
				TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass2", "testMethod2");

			context.MockUnitTestsPad.AddProject(project1);
			context.MockUnitTestsPad.AddProject(project2);
			context.MockUnitTestsPad.AddTestProject(testProject1);
			context.MockUnitTestsPad.AddTestProject(testProject2);
			
			buildProject1 = new MockBuildProjectBeforeTestRun();
			
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject1);
			
			runTestCommand.Run();
			
			buildProject1.FireBuildCompleteEvent();
			runTestCommand.CallTestsCompleted();
		}
コード例 #5
0
		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];
			}
		}
コード例 #6
0
		public TestMethodTreeNode(TestProject project, TestMethod testMethod) 
			: base(project, testMethod.Name)
		{
			this.testMethod = testMethod;
			testMethod.ResultChanged += TestMethodResultChanged;
			UpdateImageListIndex(testMethod.Result);
		}
コード例 #7
0
ファイル: TestResultTask.cs プロジェクト: nylen/SharpDevelop
		public static Task Create(TestResult result, TestProject project)
		{
			TaskType taskType = TaskType.Warning;
			FileLineReference lineRef = null;
			string message = String.Empty;
			
			if (result.IsFailure) {
				taskType = TaskType.Error;
				if (!result.StackTraceFilePosition.IsEmpty) {
					lineRef = new FileLineReference(result.StackTraceFilePosition.FileName, result.StackTraceFilePosition.Line - 1, result.StackTraceFilePosition.Column - 1);
				}
				message = GetTestFailedMessage(result);
			} else if (result.IsIgnored) {
				message = GetTestIgnoredMessage(result);
			}
			if (lineRef == null) {
				lineRef = FindTest(result.Name, project);
			}
			FileName fileName = null;
			if (lineRef != null) {
				fileName = new FileName(Path.GetFullPath(lineRef.FileName));
				int line = lineRef.Line + 1;
				return new Task(fileName, message, lineRef.Column, line, taskType);
			}
			return new Task(fileName, message, 0, 0, taskType);
		}
コード例 #8
0
		public void SetUp()
		{
			testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport();
			treeView = new DummyParserServiceTestTreeView(testFrameworks);
			
			// Create a solution with two test projects.
			solution = new Solution(new MockProjectChangeWatcher());
			
			// 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);
		}
コード例 #9
0
		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];
		}
コード例 #10
0
		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];
		}
コード例 #11
0
		/// <summary>
		/// Creates a new TestNamespaceTreeNode
		/// </summary>
		/// <remarks>
		/// Note that the Namespace child nodes are added in
		/// the constructor not whilst the node is expanding
		/// via the Initialize method. This is so the icon for the
		/// node can be updated even if the parent node is not 
		/// expanded. The alternative is to have each namespace node,
		/// even if it does not have any class child nodes, to
		/// store all the classes that are below it in the tree and
		/// update the icon based on their results. The assumption
		/// is that there are fewer namespace nodes than classes so
		/// adding the namespace nodes here does not matter. 
		/// </remarks>
		/// <param name="namespacePrefix">The first part of the
		/// namespace (including any dot characters) before this 
		/// particular namespace.</param>
		/// <param name="name">The name of the namespace without any
		/// dot characters (e.g. the name at this particular 
		/// location in the tree).</param>
		public TestNamespaceTreeNode(TestProject testProject, string namespacePrefix, string name) 
			: base(testProject, name)
		{
			ns = name;
			this.namespacePrefix = namespacePrefix;
			fullNamespace = GetFullNamespace(namespacePrefix, ns);
			GetTestClasses();
			testProject.TestClasses.TestClassAdded += TestClassAdded;
			testProject.TestClasses.TestClassRemoved += TestClassRemoved;
			
			// Add namespace nodes - do not add them on node expansion.
			foreach (string namespaceName in TestProject.GetChildNamespaces(fullNamespace)) {
				TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, fullNamespace, namespaceName);
				node.AddTo(this);
				namespaceChildNodes.Add(node);
				node.ImageIndexChanged += TestNamespaceNodeImageIndexChanged;
			}
			
			// Add a dummy node if there are no namespaces since
			// there might be class nodes which will be added 
			// lazily when the node is expanded.
			if (namespaceChildNodes.Count == 0) {
				dummyNode = new ExtTreeNode();
				Nodes.Add(dummyNode);
			}
			
			UpdateImageListIndex();
		}
コード例 #12
0
		public TestMemberTreeNode(TestProject project, TestMember testMember) 
			: base(project, testMember.Name)
		{
			this.testMember = testMember;
			testMember.ResultChanged += TestMemberResultChanged;
			UpdateImageListIndex(testMember.Result);
		}
コード例 #13
0
		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);
		}
コード例 #14
0
		public TestProjectTreeNode(TestProject project)
			: base(project, project.Name)
		{
			Nodes.Add(new ExtTreeNode());
			TestProject.TestClasses.ResultChanged += TestClassesResultChanged;
			TestProject.TestClasses.TestClassAdded += TestClassAdded;
			TestProject.TestClasses.TestClassRemoved += TestClassRemoved;
		}
コード例 #15
0
		public TestClassTreeNode(TestProject project, TestClass testClass)
			: base(project, testClass.Name)
		{
			this.testClass = testClass;
			testClass.ResultChanged += TestClassResultChanged;
			Nodes.Add(new ExtTreeNode());
			UpdateImageListIndex(testClass.Result);
		}
		public void Init()
		{
			string[] methods = new string[] { "Foo", "Bar" };
			testProject = 
				TestProjectHelper.CreateTestProjectWithTestClassTestMethods("MyClass", methods);
			
			testClass = testProject.TestClasses[0];
		}
コード例 #17
0
		public void Init()
		{
			base.InitBase();
			
			project = new MockCSharpProject();
			context.MockUnitTestsPad.AddProject(project);
			
			string[] methodNames = new string[] { "FirstTest", "SecondTest", "ThirdTest" };
			
			testProject = 
				TestProjectHelper.CreateTestProjectWithTestClassTestMethods(project,
					"MyTests.MyTestClass",
					methodNames);
			
			TestClass testClass = testProject.TestClasses[0];
			firstTestMethod = testClass.Members[0];
			secondTestMethod = testClass.Members[1];
			thirdTestMethod = testClass.Members[2];
			
			context.MockUnitTestsPad.AddTestProject(testProject);
			
			MockBuildProjectBeforeTestRun buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun();
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun);
			
			context.UnitTestingOptions.NoThread = true;
			context.UnitTestingOptions.NoShadow = true;
			context.UnitTestingOptions.NoLogo = true;
			context.UnitTestingOptions.NoDots = true;
			context.UnitTestingOptions.Labels = true;
			context.UnitTestingOptions.CreateXmlOutputFile = true;
			
			testFramework = new MockTestFramework();
			context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework);
			
			runTestCommand.Run();
			
			buildProjectBeforeTestRun.FireBuildCompleteEvent();
			
			errorTestResult = new TestResult("MyTests.MyTestClass.FirstTest");
			errorTestResult.ResultType = TestResultType.Failure;
			
			warningTestResult = new TestResult("MyTests.MyTestClass.SecondTest");
			warningTestResult.ResultType = TestResultType.Ignored;
			
			successTestResult = new TestResult("MyTests.MyTestClass.ThirdTest");
			successTestResult.ResultType = TestResultType.Success;
			
			context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true;
			MockTestRunner testRunner = runTestCommand.TestRunnersCreated[0];
			testRunner.FireTestFinishedEvent(errorTestResult);
			testRunner.FireTestFinishedEvent(warningTestResult);
			testRunner.FireTestFinishedEvent(successTestResult);
			
			context.MockUnitTestsPad.IsUpdateToolbarMethodCalled = false;
			runningTestsBeforeTestsFinishedCalled = AbstractRunTestCommand.IsRunningTest;
			runTestCommand.CallTestsCompleted();
		}
コード例 #18
0
		/// <summary>
		/// Returns the location of the specified test method in the
		/// project being tested.
		/// </summary>
		static FileLineReference FindTest(string methodName, TestProject testProject)
		{
			if (testProject != null) {
				TestMethod testMethod = testProject.TestClasses.GetTestMethod(methodName);
				if (testMethod != null) {
					return FindTest(testMethod);
				}
			}
			return null;
		}
コード例 #19
0
ファイル: TestResultTask.cs プロジェクト: nylen/SharpDevelop
		/// <summary>
		/// Returns the location of the specified test member in the
		/// project being tested.
		/// </summary>
		static FileLineReference FindTest(string memberName, TestProject testProject)
		{
			if (testProject != null) {
				TestMember testMember = testProject.TestClasses.GetTestMember(memberName);
				if (testMember != null) {
					return FindTest(testMember);
				}
			}
			return null;
		}
		public void Init()
		{
			testFrameworks = new MockRegisteredTestFrameworks();
			myTestClass = MockClass.CreateMockClassWithoutAnyAttributes();
			myTestClass.SetDotNetName("MyTests");
			testFrameworks.AddTestClass(myTestClass);
			
			oldUnit = new DefaultCompilationUnit(myTestClass.ProjectContent);
			oldUnit.Classes.Add(myTestClass);
			
			testProject = new TestProject(myTestClass.Project, myTestClass.ProjectContent, 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();
			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 Init()
		{
			testProject = 
				TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod("MyNamespace.MyClass", "MyTestMethod");
			
			if (testProject.TestClasses.Count > 0) {
				testClass = testProject.TestClasses[0];
				if (testClass.Members.Count > 0) {
					testMethod = testClass.Members[0];
				}
			}	
		}
コード例 #23
0
		public void Init()
		{
			base.InitBase();

			//Add TestFixture attribute to outer class
			outerClass.Attributes.Add(new MockAttribute("TestFixture"));
			testProject = new TestProject(null, projectContent, testFrameworks);

			//Add inner class nested in test class
			classNestedInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerTestLevel2", "MyTests.A+InnerATest+InnerTestLevel2", innerClass);
			classNestedInInnerClass.Attributes.Add(new MockAttribute("TestFixture"));
			innerClass.InnerClasses.Add(classNestedInInnerClass);
		}
コード例 #24
0
		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()
		{
			MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks();
			MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
			TestClass testClass = new TestClass(c, testFrameworks);
			
			TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks);
			testProject.TestClasses.Add(testClass);
			
			TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod");
			testResult.ResultType = TestResultType.Ignored;
			testResult.Message = "Test ignored";
			
			task = TestResultTask.Create(testResult, testProject);
		}
コード例 #26
0
		public void SetUp() {
			base.InitBase();
			
			baseClass = new MockClass(projectContent, "MyTests.BaseClass");
			testMethodInBaseClass = new MockMethod(baseClass, "BaseFoo");
			testMethodInBaseClass.Attributes.Add(new MockAttribute("Test"));
			baseClass.Methods.Add(testMethodInBaseClass);

			//Add TestFixture attribute to outer class
			outerClass.Attributes.Add(new MockAttribute("TestFixture"));

			//Add inner class nested in test class
			classNestedInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerTestLevel2", "MyTests.A+InnerATest+InnerTestLevel2", innerClass);
			innerClass.InnerClasses.Add(classNestedInInnerClass);
			classNestedInInnerClass.AddBaseClass(baseClass);
			
			testProject = new TestProject(null, projectContent, testFrameworks);
		}
コード例 #27
0
		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();
		}
コード例 #28
0
		public void TreeNodeContextMenuMatches()
		{
			using (DerivedTestTreeView treeView = new DerivedTestTreeView()) {
				ContextMenuStrip menuStrip = new ContextMenuStrip();
				treeView.ContextMenuStrip = menuStrip;
				
				// Add a root node to the tree.
				TestProject project = new TestProject(new MockCSharpProject(), new MockProjectContent(), new MockTestFrameworksWithNUnitFrameworkSupport());
				TestProjectTreeNode node = new TestProjectTreeNode(project);
				node.AddTo(treeView);
				
				// Select the tree node.
				treeView.SelectedNode = node;
				
				// Call the treeView's OnBeforeSelect so the context menu 
				// is connected to the tree node.
				treeView.CallOnBeforeSelect(new TreeViewCancelEventArgs(node, false, TreeViewAction.ByMouse));
				
				// Context menu strip on tree node should match
				// the tree view's context menu strip.
				Assert.IsTrue(Object.ReferenceEquals(menuStrip, node.ContextMenuStrip));
			}
		}
		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);
		}
コード例 #30
0
		public static TestProject CreateTestProjectWithTestClassTestMethods(IProject project, string className, string[] methodNames)
		{
			MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks();
			MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();
			c.MockProjectContent.Project = project;
			c.SetDotNetName(className);
			c.CompilationUnit.FileName = @"c:\projects\tests\MyTests.cs";
			TestClass testClass = new TestClass(c, testFrameworks);
			
			foreach (string methodName in methodNames) {
				MockMethod method = new MockMethod(c, methodName);
				method.Region = new DomRegion(4, 20);
				c.Methods.Add(method);
				
				TestMethod testMethod = new TestMethod(method);
				testClass.TestMethods.Add(testMethod);
			}
			
			c.Project.Name = "TestProject";
			TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks);
			testProject.TestClasses.Add(testClass);
			
			return testProject;
		}
コード例 #31
0
 public TestTreeNode(TestProject testProject, string text)
 {
     this.testProject = testProject;
     this.Text        = text;
     ImageIndex       = (int)TestTreeViewImageListIndex.TestNotRun;
 }
コード例 #32
0
 /// <summary>
 /// Creates a new TestNamespaceTreeNode with the specified
 /// namespace name. This node will have no namespace prefix.
 /// </summary>
 public TestNamespaceTreeNode(TestProject testProject, string name)
     : this(testProject, String.Empty, name)
 {
 }