/// <summary> /// Using static Mapper, uses <see cref="RandomValuesHelper"/> to create a new <typeparamref name="TSource"/> instance, /// maps it to a 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> /// <returns>The mapped <typeparamref name="TDestination"/> instance.</returns> public static TDestination AssertAutoMappedRandomValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester) { var source = new RandomValuesHelper().CreateInstanceWithRandomValues <TSource>(); return(mapTester.AssertAutoMappedValues(source)); }
/// <summary> /// Using static Mapper, uses <see cref="Populater"/>/<see cref="RandomValueProvider"/> /// to create a new <typeparamref name="TSource"/> instance, /// maps it to a 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="randomValueProvider">(Optional) <see cref="RandomValueProvider"/> override.</param> /// <returns>The mapped <typeparamref name="TDestination"/> instance.</returns> public static TDestination AssertAutoMappedRandomValues <TSource, TDestination>( this MapTester <TSource, TDestination> mapTester, RandomValueProvider randomValueProvider = null) { var source = new Populater().CreateAndPopulate <TSource>(randomValueProvider ?? new RandomValueProvider()); return(mapTester.AssertAutoMappedValues(source)); }
public void NullSubstitute_should_use_specified_substitute() { CreateMap(map => map.ForMember(x => x.Name).NullSubstitute("Sparky")); _source.Name = "Brian"; _mapTester.AssertAutoMappedValues(_source); _source.Name = null; _mapTester .WhereMember(x => x.Name).ShouldEqualValue("Sparky") .AssertAutoMappedValues(_source); }