Browse Source

Make sure bound property is registered.

pull/58/head
Steven Kirk 11 years ago
parent
commit
e83c2e06fd
  1. 8
      Perspex.Base/PerspexObject.cs
  2. 11
      Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs

8
Perspex.Base/PerspexObject.cs

@ -574,6 +574,14 @@ namespace Perspex
PriorityValue v;
IDescription description = source as IDescription;
if (!this.IsRegistered(property))
{
throw new InvalidOperationException(string.Format(
"Property '{0}' not registered on '{1}'",
property.Name,
this.GetType()));
}
if (!this.values.TryGetValue(property, out v))
{
v = this.CreatePriorityValue(property);

11
Tests/Perspex.Base.UnitTests/PerspexObjectTests.cs

@ -355,6 +355,17 @@ namespace Perspex.Base.UnitTests
Assert.Equal("initial", target.GetValue(Class1.FooProperty));
}
[Fact]
public void Bind_Throws_Exception_For_Unregistered_Property()
{
Class1 target = new Class1();
Assert.Throws<InvalidOperationException>(() =>
{
target.Bind(Class2.BarProperty, Observable.Return("foo"));
});
}
[Fact]
public void Bind_Sets_Subsequent_Value()
{

Loading…
Cancel
Save