Skip to content

Commit a24637c

Browse files
committed
Bugfix on RandomizerForProperty
1 parent d3c39b8 commit a24637c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

ObjectFiller/ObjectFiller.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ private void FillInternal(object objectToFill)
128128
{
129129
continue;
130130
}
131-
if (currentSetup.PropertyToRandomFunc.ContainsKey(property))
131+
if (ContainsProperty(currentSetup.PropertyToRandomFunc.Keys, property))
132132
{
133-
property.SetValue(objectToFill, currentSetup.PropertyToRandomFunc[property](), null);
133+
PropertyInfo p = GetPropertyFromProperties(currentSetup.PropertyToRandomFunc.Keys, property).Single();
134+
property.SetValue(objectToFill, currentSetup.PropertyToRandomFunc[p](), null);
134135
continue;
135136
}
136137

@@ -142,7 +143,17 @@ private void FillInternal(object objectToFill)
142143

143144
private bool IgnoreProperty(PropertyInfo property, ObjectFillerSetup currentSetup)
144145
{
145-
return currentSetup.ProperiesToIgnore.Any(x => x.MetadataToken == property.MetadataToken && x.Module.Equals(property.Module));
146+
return ContainsProperty(currentSetup.PropertiesToIgnore, property);
147+
}
148+
149+
private bool ContainsProperty(IEnumerable<PropertyInfo> properties, PropertyInfo property)
150+
{
151+
return GetPropertyFromProperties(properties, property).Any();
152+
}
153+
154+
private IEnumerable<PropertyInfo> GetPropertyFromProperties(IEnumerable<PropertyInfo> properties, PropertyInfo property)
155+
{
156+
return properties.Where(x => x.MetadataToken == property.MetadataToken && x.Module.Equals(property.Module));
146157
}
147158

148159
private object GetFilledObject(Type type, ObjectFillerSetup currentSetup)

0 commit comments

Comments
 (0)