private static void Source_initialized(SourceContext context) { var source = new ClassFiller<InputClass>().Source; context.Source = source; context.Expected = new OutputClass { BooleanProperty = source.BooleanProperty, IntegerProperty = source.IntegerProperty, StringProperty = source.StringProperty, DecimalProperty = 0, DateTimeProperty = source.DateTimeProperty, DateTimeToNullable = source.DateTimeToNullable }; context.Destination = new OutputClass(); }
private static void Map_the_property_values(SourceContext context) { var result = new MappingTester<OutputClass>().Verify(context.Destination, context.Expected); result.IsValid.ShouldBeTrue(result.ToString()); }
private static void Map_is_called_with_properties_to_ignore(SimpleMapper simpleMapper, SourceContext context) { context.Expected.DecimalProperty = 0; simpleMapper.Map(context.Source, context.Destination, new Expression<Func<OutputClass, object>>[] { x => x.DecimalProperty }); }
private static void Map_is_called_with_custom_conversions(SimpleMapper obj, SourceContext context) { context.Source.Map() .WithCustomConversion((d1, d2) => d1 == typeof(decimal) && d2 == typeof(decimal), value => (decimal)value + 1) .WithCustomConverter(new DateTimeToNullableDateTimeConverter()) .WithCustomConverters(new IntToIntConverter(), new DateTimeToDateTimeConverter(), new StringToStringConverter()) .To(context.Destination); }
private static void Inputs_configured_for_custom_conversions(SimpleMapper obj, SourceContext context) { context.Source = new ClassFiller<InputClass>().Source; context.Destination = new OutputClass(); context.Expected = new OutputClass { BooleanProperty = context.Source.BooleanProperty, DateTimeProperty = context.Source.DateTimeProperty.AddDays(-1), DateTimeToNullable = context.Source.DateTimeToNullable.AddDays(1), DecimalProperty = context.Source.DecimalProperty + 1, IntegerProperty = context.Source.IntegerProperty + 1, StringProperty = context.Source.StringProperty + "!" }; }
private static void Ignore_the_property_values_that_were_set_ignore(SourceContext context) { context.Destination.DecimalProperty.ShouldNotBeEqualTo(context.Source.DecimalProperty); }