MSTestExtensions/CombinatorialFactoryAttribute.cs
/// <summary>
/// Resolves the factory method from the test class.
/// </summary>
/// <param name="testMethod">The test method being run.</param>
/// <returns>The MethodInfo for the factory method, or null if it could not be resolved.</returns>
/// <remarks>
/// To customize how factory methods are resolved, you can inherit from this
/// type and override this method to perform the necessary logic.
/// </remarks>
Resolves the factory method from the test class.
Resolves the factory method from the test class .
protected virtual MethodInfo ResolveFactory(ITestMethod testMethod)
        {
            const BindingFlags binding = BindingFlags.Public | BindingFlags.NonPublic
                                       | BindingFlags.Static;
            Type testClassType = FactoryDeclaringType
                              ?? Type.GetType(testMethod.TestClassName)
                              ?? testMethod.MethodInfo.DeclaringType;
            if (testClassType == null)
            {
                throw new ArgumentException(
                    $"Failed to resolve type for test class {testMethod.TestClassName}."
                );
            }
            return testClassType.GetTypeInfo()
                                .GetMethod(FactoryMethodName, binding);
        }
protected virtual MethodInfo ResolveFactory ( ITestMethod testMethod ) { const BindingFlags binding = BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ; Type testClassType = FactoryDeclaringType ?? Type . GetType ( testMethod . TestClassName ) ?? testMethod . MethodInfo . DeclaringType ; if ( testClassType == null ) { throw new ArgumentException ( $" Failed to resolve type for test class  { testMethod . TestClassName } . " ) ; } return testClassType . GetTypeInfo ( ) . GetMethod ( FactoryMethodName , binding ) ; }
Resolves the factory method from the test class.
Resolves the factory method from the test class .
// Try to resolve the actual test class by its name. // It that fails, just use the test method's declaring type. // TODO: can this case ever be hit?
The MethodInfo for the factory method, or null if it could not be resolved.
The MethodInfo for the factory method or null if it could not be resolved .
testMethod
ITestMethod
The test method being run.
The test method being run .
remarks
To customize how factory methods are resolved, you can inherit from this
type and override this method to perform the necessary logic.
To customize how factory methods are resolved you can inherit from this type and override this method to perform the necessary logic .