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 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 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 NoNamespace() { MockClass mockClass = new MockClass("MyFixture"); mockClass.Namespace = String.Empty; TestClass testClass = new TestClass(mockClass); Assert.AreEqual(String.Empty, testClass.RootNamespace); }
public void TwoParentNamespaces() { MockClass mockClass = new MockClass("TestRootNamespace.Tests.MyFixture"); mockClass.Namespace = "TestRootNamespace.Tests"; TestClass testClass = new TestClass(mockClass); Assert.AreEqual("TestRootNamespace", testClass.RootNamespace); }
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 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 FullyQualifiedName_NewInstanceCreatedWithFullyQualifiedName_ReturnsFullyQualifiedName() { string expectedFullyQualifiedName = "MyNamespace.MyClass"; MockClass c = new MockClass(expectedFullyQualifiedName); string fullyQualifiedName = c.FullyQualifiedName; Assert.AreEqual(expectedFullyQualifiedName, fullyQualifiedName); }
public void DotNetName_NewInstanceCreatedWithFullyQualifiedName_ReturnsDotNetNameThatMatchesFullyQualifiedName() { string fullyQualifiedName = "MyNamespace.MyClass"; MockClass c = new MockClass(fullyQualifiedName); string dotNetName = c.DotNetName; Assert.AreEqual(fullyQualifiedName, dotNetName); }
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 ClassCreatedWithNoNamespaceInFullyQualifiedNameHasNamespaceOfEmptyString() { string fullyQualifiedName = "MyClass"; MockClass c = new MockClass(fullyQualifiedName); string expectedNamespace = String.Empty; Assert.AreEqual(expectedNamespace, c.Namespace); }
public void ClassCreatedWithNameTakenFromFullyQualifiedName() { string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass"; MockClass c = new MockClass(fullyQualifiedName); string expectedName = "MyClass"; Assert.AreEqual(expectedName, c.Name); }
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(); // 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); }
protected override ExpressionResult GetExpressionResult() { systemConsoleClass = new MockClass(projectContent, "System.Console"); systemConsoleClass.AddMethod("WriteLine"); projectContent.SetClassToReturnFromGetClass("Console", systemConsoleClass); return new ExpressionResult("Console.WriteLine", new DomRegion(2, 2), null, null); }
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; }
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 FullyQualifiedNameReturnsFullyQualifiedMethodName() { MockClass declaringType = new MockClass("MyNamespace.MyClass"); MockMethod method = new MockMethod(declaringType, "MyMethod"); string expectedName = "MyNamespace.MyClass.MyMethod"; Assert.AreEqual(expectedName, method.FullyQualifiedName); }
public void IsTestClassReturnsTrueIfClassMatchesClassPreviouslySpecified() { MockClass c = new MockClass(); testFramework.AddTestClass(c); Assert.IsTrue(testFramework.IsTestClass(c)); }
public void ClassCreatedWithExpectedDotNetName() { string fullyQualifiedName = "MyNamespace.MyClass.InnerClass"; string dotNetName = "MyNamespace.MyClass+InnerClass"; MockClass c = new MockClass(fullyQualifiedName, dotNetName); Assert.AreEqual(dotNetName, c.DotNetName); }
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() { 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(); DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(outerClass); // Create new compilation unit with inner class that has its method renamed. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); MockClass newOuterClass = new MockClass("MyTests.A"); newOuterClass.ProjectContent = projectContent; projectContent.Classes.Add(newOuterClass); newOuterClass.SetCompoundClass(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); newInnerClass.Attributes.Add(new MockAttribute("TestFixture")); newInnerClass.ProjectContent = projectContent; newInnerClass.DeclaringType = outerClass; // Declaring type is outer class. newInnerClass.SetCompoundClass(newInnerClass); newOuterClass.InnerClasses.Add(newInnerClass); MockMethod method = new MockMethod("FooBarRenamed"); method.Attributes.Add(new MockAttribute("Test")); method.DeclaringType = newInnerClass; newInnerClass.Methods.Add(method); outerClass.InnerClasses.Add(newInnerClass); // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); innerTestClass = testProject.TestClasses["MyTests.A+InnerATest"]; }
protected override ExpressionResult GetExpressionResult() { MockClass textBoxClass = new MockClass(projectContent, "System.Windows.Forms.TextBox"); projectContent.SetClassToReturnFromGetClass("System.Windows.Forms.TextBox", textBoxClass); return new ExpressionResult("MyTextBox", ExpressionContext.Default); }
public void Init() { base.InitBase(); DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(outerClass); // Create new compilation unit with inner class that has its method renamed. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", outerClass); newInnerClass.SetDotNetName("MyTests.A+InnerATest"); newInnerClass.Attributes.Add(new MockAttribute("TestFixture")); newOuterClass.InnerClasses.Add(newInnerClass); MockMethod method = new MockMethod(newInnerClass, "FooBarRenamed"); method.Attributes.Add(new MockAttribute("Test")); newInnerClass.Methods.Add(method); outerClass.InnerClasses.Add(newInnerClass); MockClass innerClassInInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest.InnerInnerTest", innerClass); innerClassInInnerClass.SetDotNetName("MyTests.A+InnerATest+InnerInnerTest"); innerClassInInnerClass.Attributes.Add(new MockAttribute("TestFixture")); newInnerClass.InnerClasses.Add(innerClassInInnerClass); // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); innerTestClass = testProject.TestClasses["MyTests.A+InnerATest"]; }
public void Init() { project = new MockCSharpProject(); c = new MockClass(); method = new MockMethod(c); selectedTests = new SelectedTests(project, namespaceFilter, c, method); }
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() { base.InitBase(); DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(outerClass); // Create new compilation unit with inner class that no longer has the TestFixture attribute. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); MockClass newOuterClass = new MockClass("MyTests.A"); newOuterClass.ProjectContent = projectContent; projectContent.Classes.Add(newOuterClass); newOuterClass.SetCompoundClass(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); newInnerClass.ProjectContent = projectContent; newInnerClass.DeclaringType = outerClass; // Declaring type is outer class. newInnerClass.SetCompoundClass(newInnerClass); newOuterClass.InnerClasses.Add(newInnerClass); // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); }
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 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)); }
public void Resolve_FieldHasNoReturnType_DoesNotThrowNullReferenceException() { MockProjectContent projectContent = new MockProjectContent(); UnitTestingUtils.MockClass c = new UnitTestingUtils.MockClass(projectContent, "Test"); projectContent.SetClassToReturnFromGetClass("self", c); DefaultField field = c.AddField("randomNumber"); field.ReturnType = null; ParseInformation parseInfo = new ParseInformation(c.CompilationUnit); ExpressionResult expression = new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default); PythonClassResolver classResolver = new PythonClassResolver(); PythonLocalVariableResolver localVariableResolver = new PythonLocalVariableResolver(classResolver); PythonMemberResolver resolver = new PythonMemberResolver(classResolver, localVariableResolver); PythonResolverContext context = new PythonResolverContext(parseInfo, expression, "class Test:\r\npass"); Assert.DoesNotThrow(delegate { resolver.Resolve(context); }); }