Skip to content

Commit 58d0891

Browse files
committed
Test coverage for callbacks based on derived source types / Removing unused code
1 parent c081d4e commit 58d0891

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

AgileMapper.UnitTests/Configuration/WhenConfiguringMappingCallbacks.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,5 +318,25 @@ public void ShouldRestrictAPostMappingCallbackBySourceType()
318318
matchingResult.Value.ShouldBe("SetByCallback");
319319
}
320320
}
321+
322+
[Fact]
323+
public void ShouldExecuteAPostMappingCallbackForADerivedType()
324+
{
325+
using (var mapper = Mapper.CreateNew())
326+
{
327+
var derivedSource = default(object);
328+
329+
mapper.WhenMapping
330+
.From<CustomerViewModel>()
331+
.To<Person>()
332+
.After.MappingEnds
333+
.Call(ctx => derivedSource = ctx.Source);
334+
335+
PersonViewModel source = new CustomerViewModel { Name = "?!?!?" };
336+
mapper.Map(source).ToANew<Person>();
337+
338+
derivedSource.ShouldBeSameAs(source);
339+
}
340+
}
321341
}
322342
}

AgileMapper/ObjectPopulation/MappingDataFactory.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@ internal static class MappingDataFactory
1515
public static readonly MethodInfo ForElementMethod = typeof(MappingDataFactory)
1616
.GetPublicStaticMethod("ForElement");
1717

18-
public static ObjectMappingData<TSource, TTarget> ForRoot<TSource, TTarget>(
19-
TSource source,
20-
TTarget target,
21-
IMappingContext mappingContext)
22-
{
23-
var mapperKey = new RootObjectMapperKey(MappingTypes.Fixed<TSource, TTarget>(), mappingContext);
24-
25-
return new ObjectMappingData<TSource, TTarget>(
26-
source,
27-
target,
28-
null,
29-
mapperKey,
30-
mappingContext,
31-
parent: null);
32-
}
33-
3418
public static ObjectMappingData<TSource, TTarget> ForChild<TSource, TTarget>(
3519
TSource source,
3620
TTarget target,

0 commit comments

Comments
 (0)