Created
January 27, 2016 21:04
-
-
Save lbugnion/db7789d29136d510549b to your computer and use it in GitHub Desktop.
MVVM Light binding framework for Xamarin also supports FallbackValue and TargetNullValue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void BindingDeepPath_DeepSourceExistingPathGraduallySettingPath_NoError() | |
{ | |
VmSource = new TestViewModel(); | |
VmTarget = new TestViewModel(); | |
const string fallback = "This is the fallback"; | |
const string targetNull = "Target is null"; | |
var binding = new Helpers.Binding<string, string>( | |
VmSource, | |
() => VmSource.Nested.Nested.Model.MyProperty, | |
VmTarget, | |
() => VmTarget.TargetProperty, | |
fallbackValue: fallback, | |
targetNullValue: targetNull); | |
Assert.AreEqual(fallback, VmTarget.TargetProperty); | |
VmSource.Nested = new TestViewModel(); | |
Assert.AreEqual(fallback, VmTarget.TargetProperty); | |
VmSource.Nested.Nested = new TestViewModel(); | |
Assert.AreEqual(fallback, VmTarget.TargetProperty); | |
VmSource.Nested.Nested.Model = new TestModel(); | |
Assert.AreEqual(targetNull, VmTarget.TargetProperty); | |
var initialValue = "Initial value"; | |
VmSource.Nested.Nested.Model.MyProperty = initialValue; | |
Assert.AreEqual(initialValue, VmTarget.TargetProperty); | |
var newValue = DateTime.Now.Ticks.ToString(); | |
VmSource.Nested.Nested.Model.MyProperty = newValue; | |
Assert.AreEqual(newValue, VmTarget.TargetProperty); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment