Esempio n. 1
0
        public void MappedTo_should_map_to_destination_type()
        {
            CreateMap();

            var dest = _source.MappedTo <Dest>();

            _mapTester.AssertMappedValues(_source, dest);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
 /// <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));
 }
Esempio n. 5
0
 private void AssertMappedValues()
 {
     AssertExceptionNotThrown.WhenExecuting(() => _mapTester.AssertMappedValues(_source, _dest));
 }
Esempio n. 6
0
 /// <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);
 }