Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace ObjectFiller.Test.BugfixTests
{
using Tynamix.ObjectFiller;



[TestClass]
public class Bug87ErrorWhenNameInParentIsSameAsParent
{
public class Parent
Expand All @@ -29,11 +29,16 @@ public class Child
public void ParentShallGetFilledWithourError()
{
Filler<Parent> filler = new Filler<Parent>();
filler.Setup()
.OnProperty(x => x.MakeTheError).Use(12345)
.SetupFor<Child>()
.OnProperty(x => x.MakeTheError).Use("TEST");

var filledObject = filler.Create();
Assert.IsNotNull(filledObject);
Assert.IsNotNull(filledObject.MakeTheError);
Assert.AreEqual(12345, filledObject.MakeTheError);
Assert.IsFalse(string.IsNullOrWhiteSpace(filledObject.Child.MakeTheError));
Assert.AreEqual("TEST", filledObject.Child.MakeTheError);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion Tynamix.ObjectFiller/Filler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,9 @@ private IEnumerable<PropertyInfo> GetPropertyFromProperties(
IEnumerable<PropertyInfo> properties,
PropertyInfo property)
{
return properties.Where(x => x.Name == property.Name && x.Module.Equals(property.Module));
return properties.Where(x => x.Name == property.Name
&& x.Module.Equals(property.Module)
&& x.DeclaringType?.AssemblyQualifiedName == property.DeclaringType?.AssemblyQualifiedName);
}

/// <summary>
Expand Down