Skip to content

Instantly share code, notes, and snippets.

@lbugnion
Created January 27, 2016 20:53
Show Gist options
  • Save lbugnion/e8f9557cd255aaf863b5 to your computer and use it in GitHub Desktop.
Save lbugnion/e8f9557cd255aaf863b5 to your computer and use it in GitHub Desktop.
MVVM Light binding framework for Xamarin supports deep paths with changing objects! Passed
[Test]
public void BindingDeepPath_DeepSourceExistingPathChangingObjects_NoError()
{
VmSource = new TestViewModel
{
Nested = new TestViewModel
{
Nested = new TestViewModel
{
Model = new TestModel
{
MyProperty = "Initial value"
}
}
}
};
VmTarget = new TestViewModel();
var binding = new Helpers.Binding<string, string>(
VmSource,
() => VmSource.Nested.Nested.Model.MyProperty,
VmTarget,
() => VmTarget.TargetProperty);
Assert.AreEqual(VmSource.Nested.Nested.Model.MyProperty, VmTarget.TargetProperty);
var newValue = DateTime.Now.Ticks.ToString();
VmSource.Nested.Nested.Model.MyProperty = newValue;
Assert.AreEqual(VmSource.Nested.Nested.Model.MyProperty, VmTarget.TargetProperty);
const string value2 = "Value 2";
VmSource.Nested = new TestViewModel
{
Nested = new TestViewModel
{
Model = new TestModel
{
MyProperty = value2
}
}
};
Assert.AreEqual(value2, VmTarget.TargetProperty);
const string value3 = "Value 3";
VmSource.Nested.Nested = new TestViewModel
{
Model = new TestModel
{
MyProperty = value3
}
};
Assert.AreEqual(value3, VmTarget.TargetProperty);
const string value4 = "Value 4";
VmSource.Nested.Nested.Model = new TestModel
{
MyProperty = value4
};
Assert.AreEqual(value4, VmTarget.TargetProperty);
const string value5 = "Value 5";
VmSource.Nested.Nested.Model.MyProperty = value5;
Assert.AreEqual(value5, VmTarget.TargetProperty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment