protected override ITest CreateTestClass(ITypeDefinition typeDefinition) { if (NUnitTestFramework.IsTestClass(typeDefinition)) { return(new NUnitTestClass(this, typeDefinition.FullTypeName)); } else { return(null); } }
public void Init() { testFramework = new NUnitTestFramework(); }
protected override bool IsTestClass(ITypeDefinition typeDefinition) { return(NUnitTestFramework.IsTestClass(typeDefinition)); }
void CreateTestFramework() { testFramework = new NUnitTestFramework(); }
public void Init() { SD.InitializeForUnitTests(); SD.Services.AddService(typeof(IParserService), MockRepository.GenerateStrictMock<IParserService>()); testFramework = new NUnitTestFramework(); }
public void IsBuildNeededBeforeTestRunReturnsTrue() { NUnitTestFramework testFramework = new NUnitTestFramework(); Assert.IsTrue(testFramework.IsBuildNeededBeforeTestRun); }
public void NUnitTestFrameworkCreateTestDebuggerReturnsNUnitTestDebugger() { NUnitTestFramework testFramework = new NUnitTestFramework(); Assert.IsInstanceOf(typeof(NUnitTestDebugger), testFramework.CreateTestDebugger()); }
public void UpdateTestClass(ITypeDefinition typeDefinition) { fullTypeName = typeDefinition.FullTypeName; if (this.NestedTestsInitialized) { int baseClassIndex = 0; foreach (IType baseType in typeDefinition.GetNonInterfaceBaseTypes()) { ITypeDefinition baseTypeDef = baseType.GetDefinition(); // Check that the base type isn't equal to System.Object or the current class itself if (baseTypeDef == null || baseTypeDef == typeDefinition || baseTypeDef.KnownTypeCode == KnownTypeCode.Object) { continue; } if (baseTypeDef.DeclaringTypeDefinition != null) { continue; // we only support inheriting from top-level classes } var baseClassName = baseTypeDef.FullTypeName; if (baseClassIndex < baseClassNames.Count && baseClassName == baseClassNames[baseClassIndex]) { // base class is already in the list, just keep it baseClassIndex++; } else { // base class is not in the list, or the remaining portion of the list differs // remove remaining portion of the list: RemoveBaseClasses(baseClassIndex); // Add new base class: parentProject.RegisterInheritedClass(baseClassName, this); baseClassNames.Add(baseClassName); baseClassIndex++; } } HashSet <ITest> newOrUpdatedNestedTests = new HashSet <ITest>(); // Update nested test classes: foreach (ITypeDefinition nestedClass in typeDefinition.NestedTypes) { if (!NUnitTestFramework.IsTestClass(nestedClass)) { continue; } NUnitTestClass nestedTestClass = FindNestedTestClass(nestedClass.Name, nestedClass.TypeParameterCount); if (nestedTestClass != null) { nestedTestClass.UpdateTestClass(nestedClass); } else { nestedTestClass = new NUnitTestClass(parentProject, nestedClass.FullTypeName); this.NestedTestCollection.Add(nestedTestClass); } newOrUpdatedNestedTests.Add(nestedTestClass); } // Get methods (not operators etc.) foreach (IMethod method in typeDefinition.GetMethods(m => m.SymbolKind == SymbolKind.Method)) { if (!NUnitTestFramework.IsTestMethod(method)) { continue; } IUnresolvedMethod unresolvedMethod = (IUnresolvedMethod)method.UnresolvedMember; string methodNameWithDeclaringType; FullTypeName derivedFixture; if (method.DeclaringTypeDefinition == typeDefinition) { derivedFixture = default(FullTypeName); // method is not inherited methodNameWithDeclaringType = method.Name; } else { if (method.DeclaringTypeDefinition == null) { continue; } derivedFixture = fullTypeName; // method is inherited methodNameWithDeclaringType = method.DeclaringTypeDefinition.Name + "." + method.Name; } NUnitTestMethod testMethod; if (method.IsOverride) { testMethod = FindTestMethodWithShortName(method.Name); } else { testMethod = FindTestMethod(methodNameWithDeclaringType); } if (testMethod != null) { testMethod.UpdateTestMethod(unresolvedMethod, derivedFixture); } else { testMethod = new NUnitTestMethod(parentProject, unresolvedMethod, derivedFixture); this.NestedTestCollection.Add(testMethod); } newOrUpdatedNestedTests.Add(testMethod); } // Remove all tests that weren't contained in the new type definition anymore: this.NestedTestCollection.RemoveAll(t => !newOrUpdatedNestedTests.Contains(t)); } }