public void MappedTo_should_map_to_destination_type() { CreateMap(); var dest = _source.MappedTo <Dest>(); _mapTester.AssertMappedValues(_source, dest); }
/// <summary> /// Using <see cref="IMapper"/> instance, /// maps <paramref name="source"/> to new <typeparamref name="TDestination"/> instance and /// calls <see cref="MapTester{TSource, TDestination}.AssertMappedValues(TSource, TDestination)"/>. /// </summary> /// <typeparam name="TSource">The type of the source.</typeparam> /// <typeparam name="TDestination">The type of the destination.</typeparam> /// <param name="mapTester">The <see cref="MapTester{TSource, TDestination}"/>.</param> /// <param name="mapper">The <see cref="IMapper"/>.</param> /// <param name="source">The source object.</param> /// <returns>The mapped <typeparamref name="TDestination"/> instance.</returns> public static TDestination AssertAutoMappedValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester, IMapper mapper, TSource source) { TDestination mapped = mapper.Map <TSource, TDestination>(source); mapTester.AssertMappedValues(source, mapped); return(mapped); }
/// <summary> /// Using <see cref="IMapper"/> instance, /// maps <paramref name="source"/> to new <typeparamref name="TDestination"/> instance and /// calls <see cref="MapTester{TSource, TDestination}.AssertMappedValues(TSource, TDestination)"/>. /// </summary> /// <typeparam name="TSource">The type of the source.</typeparam> /// <typeparam name="TDestination">The type of the destination.</typeparam> /// <param name="mapTester">The <see cref="MapTester{TSource, TDestination}"/>.</param> /// <param name="mapper">The <see cref="IMapper"/>.</param> /// <param name="source">The source object.</param> /// <returns>The mapped <typeparamref name="TDestination"/> instance.</returns> public static TDestination AssertAutoMappedValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester, IMapper mapper, TSource source) { TDestination mapped = default(TDestination); WithExceptionHandling(mapTester, () => { mapped = mapper.Map <TSource, TDestination>(source); mapTester.AssertMappedValues(source, mapped); }); return(mapped); }
/// <summary> /// Assert that all defined properties were successfully maped /// from <typeparamref name="TSource"/> to <typeparamref name="TDestination"/>. /// </summary> /// <param name="source">An instance of type <typeparamref name="TDestination"/>.</param> /// <param name="dest">An instance of type <typeparamref name="TDestination"/>.</param> /// <exception cref="MapTesterException">if dest properties don't have expected values.</exception> /// <example> /// <code><![CDATA[ /// MapTester /// .ForMap<Foo, Bar>() /// .AssertMappedValues(foo, bar); /// ]]> /// </code> /// </example> public static void AssertMappedValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester, TSource source, TDestination dest) { WithExceptionHandling(mapTester, () => mapTester.AssertMappedValues(source, dest)); }
private void AssertMappedValues() { AssertExceptionNotThrown.WhenExecuting(() => _mapTester.AssertMappedValues(_source, _dest)); }
/// <summary> /// Assert that all defined properties were successfully mapped /// from <typeparamref name="TSource"/> to <typeparamref name="TDestination"/>. /// </summary> /// <param name="mapTester">"This" <see cref="MapTester{TSource,TDestination}"/> instance.</param> /// <param name="source">An instance of type <typeparamref name="TDestination"/>.</param> /// <param name="dest">An instance of type <typeparamref name="TDestination"/>.</param> /// <exception cref="MapTesterException">if dest properties don't have expected values.</exception> /// <example> /// <code><![CDATA[ /// MapTester /// .ForMap<Foo, Bar>() /// .AssertMappedValues(foo, bar); /// ]]> /// </code> /// </example> public static void AssertMappedValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester, TSource source, TDestination dest) { mapTester.AssertMappedValues(source, dest); }