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()
		{
			base.InitBase();
			
			project = new MockCSharpProject();
			MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun();
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject);
			
			classToTest = MockClass.CreateMockClassWithoutAnyAttributes();
			classToTest.SetDotNetName("MyTestClass");
			
			treeView = new MockTestTreeView();
			treeView.SelectedProject = project;
			treeView.SelectedClass = classToTest;
			
			runTestCommand.Owner = treeView;
			
			runTestCommand.Run();
			
			buildProject.FireBuildCompleteEvent();
			
			TestResult result = new TestResult("MyTestClass");
			result.ResultType = TestResultType.Success;
			context.MockTestResultsMonitor.FireTestFinishedEvent(result);
			
			runTestCommand.CallTestsCompleted();
		}
		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 Init()
		{
			base.InitBase();
			
			project = new MockCSharpProject();
			MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun();
			context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject);
			
			methodToTest = MockMethod.CreateMockMethodWithoutAnyAttributes();
			methodToTest.FullyQualifiedName = "MyTests.MyTestClass.MyTestMethod";
			
			classToTest = methodToTest.DeclaringType as MockClass;
			classToTest.SetDotNetName("MyTests.MyTestClass");
			
			treeView = new MockTestTreeView();
			treeView.SelectedProject = project;
			treeView.SelectedMember = methodToTest;
			
			runTestCommand.Owner = treeView;
			
			runTestCommand.Run();
			
			buildProject.FireBuildCompleteEvent();
			
			context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true;
			context.MockBuildOptions.ShowErrorListAfterBuild = false;
			
			TestResult result = new TestResult("MyTests.MyTestClass.MyTestMethod");
			result.ResultType = TestResultType.Failure;
			context.MockTestResultsMonitor.FireTestFinishedEvent(result);
			
			runTestCommand.CallTestsCompleted();
		}
		public void SelectedProjectMatchesProjectServiceCurrentProject()
		{
			MockCSharpProject project = new MockCSharpProject();
			ProjectService.CurrentProject = project;
			
			Assert.AreEqual(project, runProjectTestsInPadCommand.SelectedProject);
		}
		public void NothingSpecified()
		{
			MockCSharpProject project = new MockCSharpProject();
			SelectedTests selectedTests = new SelectedTests(project);
			NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests);
			Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName);
		}
		void StartTestRunner()
		{
			FileUtility.ApplicationRootPath = @"d:\sharpdevelop";
			MockCSharpProject project = new MockCSharpProject();
			SelectedTests tests = new SelectedTests(project);
			testRunner.Start(tests);
		}
		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 IsSupportedProjectReturnsTrueForCSharpProjectFileExtensionInUpperCase()
		{
			MockCSharpProject project = new MockCSharpProject();
			project.FileName = @"d:\projects\myproj.CSPROJ";
			
			Assert.IsTrue(descriptor.IsSupportedProject(project));
		}
		public void Init()
		{
			project = new MockCSharpProject();
			c = new MockClass();
			method = new MockMethod(c);
			selectedTests = new SelectedTests(project, namespaceFilter, c, method);
		}
		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);
		}
		public void NothingSpecified()
		{
			MockCSharpProject project = new MockCSharpProject();
			UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
			helper.Initialize(project, null);
			Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.exe", helper.UnitTestApplication);
		}
		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();
		}
		public void IsSupportedProjectReturnsTrueForVBNetProject()
		{
			MockCSharpProject project = new MockCSharpProject();
			project.FileName = @"d:\projects\myproj.vbproj";
			
			Assert.IsTrue(descriptor.IsSupportedProject(project));
		}
		public void MbUnitTestFrameworkRegisteredForUseWithProjectsWithVBNetProjectFileExtension()
		{
			MockCSharpProject project = new MockCSharpProject();
			project.FileName = @"d:\projects\test\MyProj.vbproj";
			
			Assert.AreEqual(mbUnitTestFramework, testFrameworks.GetTestFrameworkForProject(project));
		}
		public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReference()
		{
			MockCSharpProject project = new MockCSharpProject();
			project.AddAssemblyReference(NRefactoryHelper.NUnitFramework);
			SD.ParserService.Stub(p => p.GetCompilation(project)).Return(project.ProjectContent.CreateCompilation());
			
			Assert.IsTrue(testFramework.IsTestProject(project));
		}
		public void Init()
		{
			testFrameworks = new MockRegisteredTestFrameworks();
			
			testFramework = new MockTestFramework();
			project = new MockCSharpProject();
			testFrameworks.AddTestFrameworkForProject(project, testFramework);
		}
		public void Init()
		{
			MockCSharpProject project = new MockCSharpProject();
			NUnitTestProject testProject = new NUnitTestProject(project);
			NUnitConsoleApplication app = new NUnitConsoleApplication(new[] { testProject });
			
			info = app.GetProcessStartInfo();
		}
		void CreateNUnitConsoleApplication()
		{
			MockCSharpProject project = new MockCSharpProject();
			selectedTests = new SelectedTests(project);
			
			options = new UnitTestingOptions(new Properties());
			nunitConsoleApp = new NUnitConsoleApplication(selectedTests, options);
		}
		public void Init()
		{
			MockCSharpProject project = new MockCSharpProject();
			SelectedTests selectedTests = new SelectedTests(project);
			NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests);
			
			info = app.GetProcessStartInfo();
		}
		MockCSharpProject CreateCSharpProjectNotSupportedByTestFramework()
		{
			var project = new MockCSharpProject();
			project.FileName = FileName.Create(@"d:\projects\MyProject\MyProject.csproj");
			fakeTestFramework = MockRepository.GenerateStrictMock<ITestFramework>();
			fakeTestFramework.Stub(f => f.IsTestProject(project)).Return(false);
			return project;
		}
		public void GetProjectFromTreeView()
		{
			MockTestTreeView mockTreeView = new MockTestTreeView();
			MSBuildBasedProject project = new MockCSharpProject();
			mockTreeView.SelectedProject = project;
			
			Assert.IsTrue(Object.ReferenceEquals(project, TestableCondition.GetProject(mockTreeView)));
		}
		public void NUnitTestRunnerCreatedWithMockTestResultsMonitor()
		{
			MockCSharpProject project = new MockCSharpProject();
			SelectedTests tests = new SelectedTests(project);
			testRunner.Start(tests);
			
			Assert.IsTrue(context.MockTestResultsMonitor.IsStartMethodCalled);
		}
		public void ProjectWithNUnitFrameworkReferenceCaseInsensitive()
		{
			IProject project = new MockCSharpProject();
			ReferenceProjectItem referenceProjectItem = new ReferenceProjectItem(project);
			referenceProjectItem.Include = "nunit.framework";
			ProjectService.AddProjectItem(project, referenceProjectItem);
			
			Assert.IsTrue(TestProject.IsTestProject(project));
		}
		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();
		}
		void CreateNUnitConsoleApplication()
		{
			project = new MockCSharpProject();
			project.FileName = FileName.Create(@"c:\projects\MyTests\MyTests.csproj");
			
			var testProject = new NUnitTestProject(project);
			options = new UnitTestingOptions(new Properties());
			nunitConsoleApp = new NUnitConsoleApplication(new [] { testProject }, options);
		}
		public void IsTestProjectReturnsTrueForProjectWithMbUnitFrameworkAssemblyReferenceIgnoringCase()
		{
			MockCSharpProject project = new MockCSharpProject();
			
			ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "MBUNIT");
			ProjectService.AddProjectItem(project, nunitFrameworkRef);
			
			Assert.IsTrue(testFramework.IsTestProject(project));
		}
		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 Init()
		{
			factory = new MockBuildProjectFactory();
			project = new MockCSharpProject();
			buildProject = new MockBuildProjectBeforeTestRun();
			factory.AddBuildProjectBeforeTestRun(buildProject);
			
			createdBuildProject = factory.CreateBuildProjectBeforeTestRun(new[] { project }) as MockBuildProjectBeforeTestRun;
		}
		public void ProjectWithNUnitFrameworkReferenceSpecificVersion()
		{
			IProject project = new MockCSharpProject();
			ReferenceProjectItem referenceProjectItem = new ReferenceProjectItem(project);
			referenceProjectItem.Include = "NUnit.Framework, Version=2.2.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77";
			ProjectService.AddProjectItem(project, referenceProjectItem);
			
			Assert.IsTrue(TestProject.IsTestProject(project));
		}
Пример #31
0
        public static SelectedTests CreateSelectedTestMethod()
        {
            MockCSharpProject project = new MockCSharpProject();

            MockMethod methodToTest = MockMethod.CreateMockMethodWithoutAnyAttributes();

            methodToTest.FullyQualifiedName = "MyTests.MyTestClass.MyTestMethod";

            MockClass classToTest = methodToTest.DeclaringType as MockClass;

            classToTest.SetDotNetName("MyTests.MyTestClass");

            MockTestTreeView treeView = new MockTestTreeView();

            treeView.SelectedProject = project;
            treeView.SelectedMethod  = methodToTest;

            return(new SelectedTests(treeView, null));
        }
Пример #32
0
        public static TestProject CreateTestProjectWithTestClassAndSingleTestMethod(string className, string methodName)
        {
            MockCSharpProject project = new MockCSharpProject();

            return(CreateTestProjectWithTestClassAndSingleTestMethod(project, className, methodName));
        }
Пример #33
0
        public static TestProject CreateTestProjectWithTestClassTestMethods(string className, string[] methodNames)
        {
            MockCSharpProject project = new MockCSharpProject();

            return(CreateTestProjectWithTestClassTestMethods(project, className, methodNames));
        }