Skip to content

Commit 9427a16

Browse files
authored
Merge pull request #99 from Tynamix/feature/BUG_87
Bug #87 fixed
2 parents 6884181 + f081ed4 commit 9427a16

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Tynamix.ObjectFiller.Test/BugfixTests/Bug87ErrorWhenNameInParentIsSameAsParent.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace ObjectFiller.Test.BugfixTests
88
{
99
using Tynamix.ObjectFiller;
1010

11-
1211

12+
[TestClass]
1313
public class Bug87ErrorWhenNameInParentIsSameAsParent
1414
{
1515
public class Parent
@@ -29,11 +29,16 @@ public class Child
2929
public void ParentShallGetFilledWithourError()
3030
{
3131
Filler<Parent> filler = new Filler<Parent>();
32+
filler.Setup()
33+
.OnProperty(x => x.MakeTheError).Use(12345)
34+
.SetupFor<Child>()
35+
.OnProperty(x => x.MakeTheError).Use("TEST");
3236

3337
var filledObject = filler.Create();
3438
Assert.IsNotNull(filledObject);
35-
Assert.IsNotNull(filledObject.MakeTheError);
39+
Assert.AreEqual(12345, filledObject.MakeTheError);
3640
Assert.IsFalse(string.IsNullOrWhiteSpace(filledObject.Child.MakeTheError));
41+
Assert.AreEqual("TEST", filledObject.Child.MakeTheError);
3742
}
3843
}
3944
}

Tynamix.ObjectFiller/Filler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ private IEnumerable<PropertyInfo> GetPropertyFromProperties(
962962
IEnumerable<PropertyInfo> properties,
963963
PropertyInfo property)
964964
{
965-
return properties.Where(x => x.Name == property.Name && x.Module.Equals(property.Module));
965+
return properties.Where(x => x.Name == property.Name
966+
&& x.Module.Equals(property.Module)
967+
&& x.DeclaringType?.AssemblyQualifiedName == property.DeclaringType?.AssemblyQualifiedName);
966968
}
967969

968970
/// <summary>

0 commit comments

Comments
 (0)