public void Should_copy_and_convert_source_to_target() { var target = new BasicTarget(); var source = CreateSource(); var binder = new ModelViewBinder <BasicSource>(source); binder.Bind(e => e.B, target, e => e.X, Convert.ToString); binder.FillTargets(); Assert.True(source.B.ToString() == target.X); }
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_source_to_target() { var target = new BasicTarget(); var source = CreateSource(); var binder = new ModelViewBinder <BasicSource>(source); binder.Bind(e => e.A, target, e => e.X); binder.Bind(e => e.B, target, e => e.Y); binder.Bind(e => e.C, target, e => e.Z); binder.FillTargets(); var result = source.A == target.X && source.B == target.Y && source.C == target.Z; Assert.True(result); }
public void Should_copy_source_to_target_and_run_a_callback() { var target = new BasicTarget(); var source = CreateSource(); var binder = new ModelViewBinder <BasicSource>(source); var runned = false; binder.Bind(e => e.A, target, e => e.X).Then(() => runned = true); binder.FillTargets(); var result = source.A == target.X && runned; Assert.True(result); }