private static TestInfo GetTestInfo(Guid id, MethodInfo method, Type testedAbstraction, TestSuiteInfo suiteInfo, Type testedType) { CheckTestability(suiteInfo.TesterType, testedType); var testAttribute = method.Attribute <PerfTestAttribute>(); if (testAttribute == null) { throw new ArgumentNullException("method"); } if (method.ReturnType != typeof(void) || !method.HasParameterSignature(new[] { testedAbstraction })) { throw new ArgumentException("Incorrect parameter signature"); } if (testedType.IsGenericType) { // Fill the generic type arguments of the loaded generic type // with the tested abstraction interface actual generic type arguments. // Example: tested abstraction = IList<int>, tested type = List<T> // This line converts List<T> in List<int> testedType = testedType.MakeGenericType(testedAbstraction.GetGenericArguments()); } TestInfo result; var ignoreAttribute = method.Attribute <PerfIgnoreAttribute>(); if (ignoreAttribute == null) { result = new TestInfo { TestId = id, TestDescription = testAttribute.Description, TestMethodName = method.Name, TestedType = testedType, Suite = suiteInfo }; } else { result = new TestInfoIgnored { TestId = id, TestDescription = testAttribute.Description, TestMethodName = method.Name, IgnoreMessage = ignoreAttribute.Message, TestedType = testedType, Suite = suiteInfo }; } return(result); }
private static Type DetermineTypeToResolve(MethodInfo method) { ResolveToAttribute resolveToAttribute = method.Attribute<ResolveToAttribute>(); if (resolveToAttribute == null) { return method.ReturnType; } if (resolveToAttribute.ResolveTo.IsGenericTypeDefinition) { return resolveToAttribute.ResolveTo.MakeGenericType(method.GetGenericArguments()); } return resolveToAttribute.ResolveTo; }