diff --git a/Perspex.UnitTests/Controls/ContentControlTests.cs b/Perspex.UnitTests/Controls/ContentControlTests.cs
index 4a9cf0b24a..5c42fc3a5a 100644
--- a/Perspex.UnitTests/Controls/ContentControlTests.cs
+++ b/Perspex.UnitTests/Controls/ContentControlTests.cs
@@ -71,7 +71,10 @@ namespace Perspex.UnitTests.Controls
Border border = new Border();
border.Background = new Perspex.Media.SolidColorBrush(0xffffffff);
ContentPresenter contentPresenter = new ContentPresenter();
- contentPresenter.SetValue(ContentPresenter.ContentProperty, parent.GetObservable(ContentControl.ContentProperty));
+ contentPresenter.Bind(
+ ContentPresenter.ContentProperty,
+ parent.GetObservable(ContentControl.ContentProperty),
+ BindingPriority.Template);
border.Content = contentPresenter;
return border;
});
diff --git a/Perspex.UnitTests/Perspex.UnitTests.csproj b/Perspex.UnitTests/Perspex.UnitTests.csproj
index aecd2461e4..7e88ba4225 100644
--- a/Perspex.UnitTests/Perspex.UnitTests.csproj
+++ b/Perspex.UnitTests/Perspex.UnitTests.csproj
@@ -71,6 +71,7 @@
+
diff --git a/Perspex.UnitTests/PerspexObjectTests.cs b/Perspex.UnitTests/PerspexObjectTests.cs
index 93e286a727..54088d66cb 100644
--- a/Perspex.UnitTests/PerspexObjectTests.cs
+++ b/Perspex.UnitTests/PerspexObjectTests.cs
@@ -249,7 +249,7 @@ namespace Perspex.UnitTests
Class1 source = new Class1();
source.SetValue(Class1.FooProperty, "initial");
- target.SetValue(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
+ target.Bind(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
Assert.AreEqual("initial", target.GetValue(Class1.FooProperty));
}
@@ -273,7 +273,7 @@ namespace Perspex.UnitTests
Class1 source = new Class1();
source.SetValue(Class1.FooProperty, "initial");
- target.SetValue(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
+ target.Bind(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
source.SetValue(Class1.FooProperty, "subsequent");
Assert.AreEqual("subsequent", target.GetValue(Class1.FooProperty));
@@ -286,7 +286,7 @@ namespace Perspex.UnitTests
Class1 source = new Class1();
source.SetValue(Class1.FooProperty, "initial");
- target.SetValue(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
+ target.Bind(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
target.ClearValue(Class1.FooProperty);
source.SetValue(Class1.FooProperty, "newvalue");
@@ -300,7 +300,7 @@ namespace Perspex.UnitTests
Class1 source = new Class1();
source.SetValue(Class1.FooProperty, "initial");
- target.SetValue(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
+ target.Bind(Class1.FooProperty, source.GetObservable(Class1.FooProperty));
target.SetValue(Class1.FooProperty, "reset");
source.SetValue(Class1.FooProperty, "newvalue");
@@ -321,87 +321,93 @@ namespace Perspex.UnitTests
[TestMethod]
public void StyleBinding_Overrides_Default_Value()
{
- Class1 target = new Class1();
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
- target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(true));
+ //target.Bind(Class1.FooProperty, "stylevalue", Observable.Return(true));
- Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
+ //Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
}
[TestMethod]
public void StyleBinding_Doesnt_Override_Local_Value()
{
- Class1 target = new Class1();
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
- target.SetValue(Class1.FooProperty, "newvalue");
- target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(true));
+ //target.SetValue(Class1.FooProperty, "newvalue");
+ //target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(true));
- Assert.AreEqual("newvalue", target.GetValue(Class1.FooProperty));
+ //Assert.AreEqual("newvalue", target.GetValue(Class1.FooProperty));
}
[TestMethod]
public void StyleBinding_Deactivated_Doesnt_Override_Default_Value()
{
- Class1 target = new Class1();
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
- target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(false));
+ //target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(false));
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
}
[TestMethod]
public void StyleBinding_Toggles_On_Activation()
{
- Class1 target = new Class1();
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
- Subject source = new Subject();
- target.SetValue(Class1.FooProperty, "stylevalue", source);
+ //Subject source = new Subject();
+ //target.SetValue(Class1.FooProperty, "stylevalue", source);
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
- source.OnNext(true);
- Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
- source.OnNext(false);
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //source.OnNext(true);
+ //Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
+ //source.OnNext(false);
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
}
[TestMethod]
public void StyleBinding_Detaches_OnCompleted()
{
- Class1 target = new Class1();
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
- Subject source = new Subject();
- target.SetValue(Class1.FooProperty, "stylevalue", source);
+ //Subject source = new Subject();
+ //target.SetValue(Class1.FooProperty, "stylevalue", source);
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
- source.OnNext(true);
- Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
- source.OnCompleted();
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //source.OnNext(true);
+ //Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
+ //source.OnCompleted();
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
}
[TestMethod]
public void Later_StyleBindings_Have_Precedence()
{
- Class1 target = new Class1();
-
- Subject source1 = new Subject();
- Subject source2 = new Subject();
- target.SetValue(Class1.FooProperty, "style1", source1);
- target.SetValue(Class1.FooProperty, "style2", source2);
-
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
- source1.OnNext(true);
- Assert.AreEqual("style1", target.GetValue(Class1.FooProperty));
- source2.OnNext(true);
- Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
- source1.OnNext(false);
- Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
- source2.OnNext(false);
- Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
- source2.OnNext(true);
- Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
- source1.OnNext(true);
- Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
+ throw new NotImplementedException();
+ //Class1 target = new Class1();
+
+ //Subject source1 = new Subject();
+ //Subject source2 = new Subject();
+ //target.SetValue(Class1.FooProperty, "style1", source1);
+ //target.SetValue(Class1.FooProperty, "style2", source2);
+
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //source1.OnNext(true);
+ //Assert.AreEqual("style1", target.GetValue(Class1.FooProperty));
+ //source2.OnNext(true);
+ //Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
+ //source1.OnNext(false);
+ //Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
+ //source2.OnNext(false);
+ //Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
+ //source2.OnNext(true);
+ //Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
+ //source1.OnNext(true);
+ //Assert.AreEqual("style2", target.GetValue(Class1.FooProperty));
}
private class Class1 : PerspexObject
diff --git a/Perspex.UnitTests/PriorityValueTEsts.cs b/Perspex.UnitTests/PriorityValueTEsts.cs
new file mode 100644
index 0000000000..f198161691
--- /dev/null
+++ b/Perspex.UnitTests/PriorityValueTEsts.cs
@@ -0,0 +1,201 @@
+// -----------------------------------------------------------------------
+//
+// Copyright 2013 MIT Licence. See licence.md for more information.
+//
+// -----------------------------------------------------------------------
+
+namespace Perspex.UnitTests
+{
+ using System;
+ using System.Linq;
+ using System.Reactive.Disposables;
+ using System.Reactive.Linq;
+ using System.Reactive.Subjects;
+ using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+ [TestClass]
+ public class PriorityValueTests
+ {
+ [TestMethod]
+ public void Initial_Value_Should_Be_UnsetValue()
+ {
+ var target = new PriorityValue();
+
+ Assert.AreSame(PerspexProperty.UnsetValue, target.Value);
+ }
+
+ [TestMethod]
+ public void First_Binding_Sets_Value()
+ {
+ var target = new PriorityValue();
+
+ target.Add(this.Single("foo"), 0);
+
+ Assert.AreEqual("foo", target.Value);
+ }
+
+ [TestMethod]
+ public void Changing_Binding_Should_Set_Value()
+ {
+ var target = new PriorityValue();
+ var subject = new BehaviorSubject("foo");
+
+ target.Add(subject, 0);
+ Assert.AreEqual("foo", target.Value);
+ subject.OnNext("bar");
+ Assert.AreEqual("bar", target.Value);
+ }
+
+ [TestMethod]
+ public void Binding_With_Lower_Priority_Has_Precedence()
+ {
+ var target = new PriorityValue();
+
+ target.Add(this.Single("foo"), 1);
+ target.Add(this.Single("bar"), 0);
+ target.Add(this.Single("baz"), 1);
+
+ Assert.AreEqual("bar", target.Value);
+ }
+
+ [TestMethod]
+ public void Later_Binding_With_Same_Priority_Should_Take_Precedence()
+ {
+ var target = new PriorityValue();
+
+ target.Add(this.Single("foo"), 1);
+ target.Add(this.Single("bar"), 0);
+ target.Add(this.Single("baz"), 0);
+ target.Add(this.Single("qux"), 1);
+
+ Assert.AreEqual("baz", target.Value);
+ }
+
+ [TestMethod]
+ public void Changing_Binding_With_Lower_Priority_Should_Set_Not_Value()
+ {
+ var target = new PriorityValue();
+ var subject = new BehaviorSubject("bar");
+
+ target.Add(this.Single("foo"), 0);
+ target.Add(subject, 1);
+ Assert.AreEqual("foo", target.Value);
+ subject.OnNext("baz");
+ Assert.AreEqual("foo", target.Value);
+ }
+
+ [TestMethod]
+ public void UnsetValue_Should_Fall_Back_To_Next_Binding()
+ {
+ var target = new PriorityValue();
+ var subject = new BehaviorSubject