public void Should_copy_and_convert_target_to_source() { var target = new BasicTarget { X = "9", Y = 1, Z = true }; var source = CreateSource(); var binder = new ModelViewBinder <BasicSource>(source); binder.Bind(e => e.B, target, e => e.X, Convert.ToString, int.Parse); binder.FillSource(); Assert.True(source.B.ToString() == target.X); }
public void Should_copy_target_to_source() { var target = new BasicTarget { X = "1", Y = 1, Z = true }; var source = CreateSource(); var binder = new ModelViewBinder <BasicSource>(source); binder.Bind(e => e.A, target, e => e.X) .Bind(e => e.B, target, e => e.Y) .Bind(e => e.C, target, e => e.Z); binder.FillSource(); var result = source.A == target.X && source.B == target.Y && source.C == target.Z; Assert.True(result); }