public void AspectDNG_CheckIfHooksDllContainsAndAspectDngAspect() { String sHooksDll = DngConfig.copyCurrentDllToTempFolder(); Assert.IsTrue(File.Exists(sHooksDll), "AspectDng.exe doesn't exist: {0}", sHooksDll); bool bContainsAspect = CecilCodeSearch.findInAssembly_CustomAttribute(sHooksDll, "AroundBody") || CecilCodeSearch.findInAssembly_CustomAttribute(sHooksDll, "AroundCall"); Assert.IsTrue(bContainsAspect, "Hook Dll did not contain an AspectDng aspect"); }
public static IEnumerable <ILoadedXRule> getXRulesWithUnitTests_FromAssemblies(IEnumerable <string> assembliesWithUnitTests) { var xRuleSource = "from Unit Tests"; var xLoadedXRules = new List <ILoadedXRule>(); try { foreach (var file in assembliesWithUnitTests) { var reflectionAssembly = PublicDI.reflection.getAssembly(file); // we will need the reflection assembly object below if (reflectionAssembly != null) { var nUnit_testFixtures = CecilCodeSearch.getTypesWithAttribute(file, nUnit_ClassAttribute); foreach (var nUnit_testFixture in nUnit_testFixtures) { var reflectionType = PublicDI.reflection.getType(reflectionAssembly, nUnit_testFixture.FullName); if (reflectionType != null) { var nUnit_tests = CecilCodeSearch.getMethodsWithAttribute(nUnit_testFixture, nUnit_MethodAttribute); if (nUnit_tests.Count > 0) { var xRule = new KXRule { Name = nUnit_testFixture.Name }; var loadedXRule = new KLoadedXRule(xRule, xRuleSource); foreach (var nUnit_test in nUnit_tests) { var methodInfo = CecilConvert.getMethodInfoFromMethodDefinition(reflectionType, nUnit_test); if (methodInfo != null) { var xRuleAttribute = new XRuleAttribute { Name = nUnit_test.Name }; loadedXRule.methods.Add(xRuleAttribute, methodInfo); } // loadedXRule.methods.Add(xRuleAttribute,test.); } xLoadedXRules.Add(loadedXRule); } } } } } } catch (Exception ex) { PublicDI.log.error("In getXRulesWithUnitTests_FromAssemblies: {0}", ex.Message); } return(xLoadedXRules); }
public static List <String> getAssembliesWithUnitTest(IEnumerable <string> filesToSearch) { var assembliesWithUnitTest = new List <String>(); var unitTestAttribute = "TestAttribute"; var assembliesThatReferenceNUnit = getAssembliesThatReferenceNUnit(filesToSearch); foreach (var file in assembliesThatReferenceNUnit) { if (CecilCodeSearch.findInAssembly_CustomAttribute(file, unitTestAttribute)) { assembliesWithUnitTest.Add(file); } } return(assembliesWithUnitTest); }