Skip to content

Commit c081d4e

Browse files
committed
Test coverage for expression replacement within complex type member bindings
1 parent 72afbaf commit c081d4e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

AgileMapper.UnitTests/Configuration/WhenConfiguringObjectCreation.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ public void ShouldUseAConfiguredFactoryForAGivenType()
3131
}
3232
}
3333

34+
[Fact]
35+
public void ShouldUseAConfiguredFactoryWithAComplexTypeMemberBinding()
36+
{
37+
using (var mapper = Mapper.CreateNew())
38+
{
39+
mapper.WhenMapping
40+
.InstancesOf<PublicCtor<Address>>()
41+
.CreateUsing(ctx => new PublicCtor<Address>(new Address()) { Value = { Line2 = "Some Street" } });
42+
43+
var source = new PublicField<PersonViewModel> { Value = new PersonViewModel() };
44+
var target = new PublicSetMethod<PublicCtor<Address>>();
45+
var result = mapper.Map(source).OnTo(target);
46+
47+
result.Value.ShouldNotBeNull();
48+
result.Value.Value.ShouldNotBeNull();
49+
result.Value.Value.Line2.ShouldBe("Some Street");
50+
}
51+
}
52+
3453
[Fact]
3554
public void ShouldUseAConfiguredFactoryForASpecifiedSourceAndTargetType()
3655
{

0 commit comments

Comments
 (0)