diff --git a/src/SimpleFixture/Attributes/AttributeHelper.cs b/src/SimpleFixture/Attributes/AttributeHelper.cs index c7c4fe1..961713b 100644 --- a/src/SimpleFixture/Attributes/AttributeHelper.cs +++ b/src/SimpleFixture/Attributes/AttributeHelper.cs @@ -106,7 +106,7 @@ public static IEnumerable GetAttributes(ParameterInfo parameterInfo) where /// /// public static object[] GetData(ParameterInfo parameterInfo) - { + { var fixture = CreateFixture(parameterInfo); var value = GetValueForParameter(parameterInfo.Member as MethodInfo, parameterInfo, fixture, @@ -123,6 +123,18 @@ public static object[] GetData(ParameterInfo parameterInfo) public static object[] GetData(MethodInfo testMethod, object[] parameters) { var fixture = CreateFixture(testMethod); + + return GetData(fixture, testMethod, parameters); + } + + /// Returns the data to be used to test the theory. + /// + /// The method that is being tested + /// + /// One or more sets of theory data. Each invocation of the test method + /// is represented by a single object array. + public static object[] GetData(Fixture fixture, MethodInfo testMethod, object[] parameters) + { var returnParameters = new List(); var externalParameters = new List(parameters); @@ -144,7 +156,7 @@ public static object[] GetData(MethodInfo testMethod, object[] parameters) /// /// /// - private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo parameter, + private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo parameter, Fixture fixture, List externalParameters) { if (parameter.ParameterType == typeof(Fixture)) @@ -180,14 +192,14 @@ private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo } else if (attribute is LocateAttribute) { - var locateAttribute = (LocateAttribute) attribute; + var locateAttribute = (LocateAttribute)attribute; parameterValue = LocateValue(fixture, parameter, locateAttribute); found = true; } else if (attribute is GenerateAttribute) { - var generateAttribute = (GenerateAttribute) attribute; + var generateAttribute = (GenerateAttribute)attribute; parameterValue = GenerateValue(fixture, parameter, generateAttribute); found = true; @@ -215,7 +227,7 @@ private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo else if (externalParameters[0] is Type && parameter.ParameterType.GetTypeInfo().IsAssignableFrom(((Type)externalParameters[0]).GetTypeInfo())) { - var locateType = (Type) externalParameters[0]; + var locateType = (Type)externalParameters[0]; externalParameters.RemoveAt(0); found = true; parameterValue = @@ -234,7 +246,7 @@ private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo return parameterValue; } - + /// /// Generate value for parameter