|
|
@ -14,7 +14,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Initial_Value_Should_Be_UnsetValue() |
|
|
public void Initial_Value_Should_Be_UnsetValue() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
Assert.Same(PerspexProperty.UnsetValue, target.Value); |
|
|
Assert.Same(PerspexProperty.UnsetValue, target.Value); |
|
|
} |
|
|
} |
|
|
@ -22,7 +22,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void First_Binding_Sets_Value() |
|
|
public void First_Binding_Sets_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
|
|
|
|
|
|
@ -32,7 +32,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Changing_Binding_Should_Set_Value() |
|
|
public void Changing_Binding_Should_Set_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var subject = new BehaviorSubject<string>("foo"); |
|
|
var subject = new BehaviorSubject<string>("foo"); |
|
|
|
|
|
|
|
|
target.Add(subject, 0); |
|
|
target.Add(subject, 0); |
|
|
@ -44,7 +44,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Setting_Direct_Value_Should_Override_Binding() |
|
|
public void Setting_Direct_Value_Should_Override_Binding() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
target.SetValue("bar", 0); |
|
|
target.SetValue("bar", 0); |
|
|
@ -55,7 +55,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Binding_Firing_Should_Override_Direct_Value() |
|
|
public void Binding_Firing_Should_Override_Direct_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
|
|
|
|
|
|
target.Add(source, 0); |
|
|
target.Add(source, 0); |
|
|
@ -69,7 +69,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Earlier_Binding_Firing_Should_Override_Later_Priority_0() |
|
|
public void Earlier_Binding_Firing_Should_Override_Later_Priority_0() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var nonActive = new BehaviorSubject<object>("na"); |
|
|
var nonActive = new BehaviorSubject<object>("na"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
|
|
|
|
|
|
@ -85,7 +85,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Earlier_Binding_Firing_Should_Not_Override_Later_Priority_1() |
|
|
public void Earlier_Binding_Firing_Should_Not_Override_Later_Priority_1() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var nonActive = new BehaviorSubject<object>("na"); |
|
|
var nonActive = new BehaviorSubject<object>("na"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Binding_Completing_Should_Revert_To_Direct_Value() |
|
|
public void Binding_Completing_Should_Revert_To_Direct_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
var source = new BehaviorSubject<object>("initial"); |
|
|
|
|
|
|
|
|
target.Add(source, 0); |
|
|
target.Add(source, 0); |
|
|
@ -117,7 +117,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Binding_With_Lower_Priority_Has_Precedence() |
|
|
public void Binding_With_Lower_Priority_Has_Precedence() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 1); |
|
|
target.Add(Single("foo"), 1); |
|
|
target.Add(Single("bar"), 0); |
|
|
target.Add(Single("bar"), 0); |
|
|
@ -129,7 +129,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Later_Binding_With_Same_Priority_Should_Take_Precedence() |
|
|
public void Later_Binding_With_Same_Priority_Should_Take_Precedence() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 1); |
|
|
target.Add(Single("foo"), 1); |
|
|
target.Add(Single("bar"), 0); |
|
|
target.Add(Single("bar"), 0); |
|
|
@ -142,7 +142,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Changing_Binding_With_Lower_Priority_Should_Set_Not_Value() |
|
|
public void Changing_Binding_With_Lower_Priority_Should_Set_Not_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var subject = new BehaviorSubject<string>("bar"); |
|
|
var subject = new BehaviorSubject<string>("bar"); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
@ -155,7 +155,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void UnsetValue_Should_Fall_Back_To_Next_Binding() |
|
|
public void UnsetValue_Should_Fall_Back_To_Next_Binding() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var subject = new BehaviorSubject<object>("bar"); |
|
|
var subject = new BehaviorSubject<object>("bar"); |
|
|
|
|
|
|
|
|
target.Add(subject, 0); |
|
|
target.Add(subject, 0); |
|
|
@ -171,7 +171,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Adding_Value_Should_Call_OnNext() |
|
|
public void Adding_Value_Should_Call_OnNext() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
bool called = false; |
|
|
bool called = false; |
|
|
|
|
|
|
|
|
target.Changed.Subscribe(value => called = value.Item1 == PerspexProperty.UnsetValue && (string)value.Item2 == "foo"); |
|
|
target.Changed.Subscribe(value => called = value.Item1 == PerspexProperty.UnsetValue && (string)value.Item2 == "foo"); |
|
|
@ -183,7 +183,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Changing_Value_Should_Call_OnNext() |
|
|
public void Changing_Value_Should_Call_OnNext() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var subject = new BehaviorSubject<object>("foo"); |
|
|
var subject = new BehaviorSubject<object>("foo"); |
|
|
bool called = false; |
|
|
bool called = false; |
|
|
|
|
|
|
|
|
@ -197,7 +197,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Disposing_A_Binding_Should_Revert_To_Next_Value() |
|
|
public void Disposing_A_Binding_Should_Revert_To_Next_Value() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
var disposable = target.Add(Single("bar"), 0); |
|
|
var disposable = target.Add(Single("bar"), 0); |
|
|
@ -210,7 +210,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Disposing_A_Binding_Should_Remove_BindingEntry() |
|
|
public void Disposing_A_Binding_Should_Remove_BindingEntry() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
var disposable = target.Add(Single("bar"), 0); |
|
|
var disposable = target.Add(Single("bar"), 0); |
|
|
@ -223,7 +223,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Completing_A_Binding_Should_Revert_To_Previous_Binding() |
|
|
public void Completing_A_Binding_Should_Revert_To_Previous_Binding() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var source = new BehaviorSubject<object>("bar"); |
|
|
var source = new BehaviorSubject<object>("bar"); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
@ -237,7 +237,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Completing_A_Binding_Should_Revert_To_Lower_Priority() |
|
|
public void Completing_A_Binding_Should_Revert_To_Lower_Priority() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var source = new BehaviorSubject<object>("bar"); |
|
|
var source = new BehaviorSubject<object>("bar"); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 1); |
|
|
target.Add(Single("foo"), 1); |
|
|
@ -251,7 +251,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Completing_A_Binding_Should_Remove_BindingEntry() |
|
|
public void Completing_A_Binding_Should_Remove_BindingEntry() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(string)); |
|
|
var target = new PriorityValue(null, "Test", typeof(string)); |
|
|
var subject = new BehaviorSubject<object>("bar"); |
|
|
var subject = new BehaviorSubject<object>("bar"); |
|
|
|
|
|
|
|
|
target.Add(Single("foo"), 0); |
|
|
target.Add(Single("foo"), 0); |
|
|
@ -265,7 +265,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Direct_Value_Should_Be_Coerced() |
|
|
public void Direct_Value_Should_Be_Coerced() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, 10)); |
|
|
var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, 10)); |
|
|
|
|
|
|
|
|
target.SetValue(5, 0); |
|
|
target.SetValue(5, 0); |
|
|
Assert.Equal(5, target.Value); |
|
|
Assert.Equal(5, target.Value); |
|
|
@ -276,7 +276,7 @@ namespace Perspex.Base.UnitTests |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Bound_Value_Should_Be_Coerced() |
|
|
public void Bound_Value_Should_Be_Coerced() |
|
|
{ |
|
|
{ |
|
|
var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, 10)); |
|
|
var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, 10)); |
|
|
var source = new Subject<object>(); |
|
|
var source = new Subject<object>(); |
|
|
|
|
|
|
|
|
target.Add(source, 0); |
|
|
target.Add(source, 0); |
|
|
@ -290,7 +290,7 @@ namespace Perspex.Base.UnitTests |
|
|
public void Revalidate_Should_ReCoerce_Value() |
|
|
public void Revalidate_Should_ReCoerce_Value() |
|
|
{ |
|
|
{ |
|
|
var max = 10; |
|
|
var max = 10; |
|
|
var target = new PriorityValue("Test", typeof(int), x => Math.Min((int)x, max)); |
|
|
var target = new PriorityValue(null, "Test", typeof(int), x => Math.Min((int)x, max)); |
|
|
var source = new Subject<object>(); |
|
|
var source = new Subject<object>(); |
|
|
|
|
|
|
|
|
target.Add(source, 0); |
|
|
target.Add(source, 0); |
|
|
|