|
|
|
@ -261,7 +261,7 @@ namespace Perspex.UnitTests |
|
|
|
Class1 source = new Class1(); |
|
|
|
|
|
|
|
source.SetValue(Class1.FooProperty, "initial"); |
|
|
|
target.SetValue((PerspexProperty)Class1.FooProperty, source.GetObservable(Class1.FooProperty)); |
|
|
|
target.Bind((PerspexProperty)Class1.FooProperty, source.GetObservable(Class1.FooProperty)); |
|
|
|
|
|
|
|
Assert.AreEqual("initial", target.GetValue(Class1.FooProperty)); |
|
|
|
} |
|
|
|
@ -321,93 +321,33 @@ namespace Perspex.UnitTests |
|
|
|
[TestMethod] |
|
|
|
public void StyleBinding_Overrides_Default_Value() |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
Class1 target = new Class1(); |
|
|
|
|
|
|
|
//target.Bind(Class1.FooProperty, "stylevalue", Observable.Return(true));
|
|
|
|
target.Bind(Class1.FooProperty, this.Single("stylevalue"), BindingPriority.Style); |
|
|
|
|
|
|
|
//Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty));
|
|
|
|
Assert.AreEqual("stylevalue", target.GetValue(Class1.FooProperty)); |
|
|
|
} |
|
|
|
|
|
|
|
[TestMethod] |
|
|
|
public void StyleBinding_Doesnt_Override_Local_Value() |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
|
|
|
|
//target.SetValue(Class1.FooProperty, "newvalue");
|
|
|
|
//target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(true));
|
|
|
|
|
|
|
|
//Assert.AreEqual("newvalue", target.GetValue(Class1.FooProperty));
|
|
|
|
} |
|
|
|
|
|
|
|
[TestMethod] |
|
|
|
public void StyleBinding_Deactivated_Doesnt_Override_Default_Value() |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
|
|
|
|
//target.SetValue(Class1.FooProperty, "stylevalue", Observable.Return(false));
|
|
|
|
|
|
|
|
//Assert.AreEqual("foodefault", target.GetValue(Class1.FooProperty));
|
|
|
|
} |
|
|
|
|
|
|
|
[TestMethod] |
|
|
|
public void StyleBinding_Toggles_On_Activation() |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
|
|
|
|
//Subject<bool> source = new Subject<bool>();
|
|
|
|
//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));
|
|
|
|
} |
|
|
|
|
|
|
|
[TestMethod] |
|
|
|
public void StyleBinding_Detaches_OnCompleted() |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
Class1 target = new Class1(); |
|
|
|
|
|
|
|
//Subject<bool> source = new Subject<bool>();
|
|
|
|
//target.SetValue(Class1.FooProperty, "stylevalue", source);
|
|
|
|
target.SetValue(Class1.FooProperty, "newvalue"); |
|
|
|
target.Bind(Class1.FooProperty, this.Single("stylevalue"), BindingPriority.Style); |
|
|
|
|
|
|
|
//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("newvalue", target.GetValue(Class1.FooProperty)); |
|
|
|
} |
|
|
|
|
|
|
|
[TestMethod] |
|
|
|
public void Later_StyleBindings_Have_Precedence() |
|
|
|
/// <summary>
|
|
|
|
/// Returns an observable that returns a single value but does not complete.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">The type of the observable.</typeparam>
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
/// <returns>The observable.</returns>
|
|
|
|
private IObservable<T> Single<T>(T value) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
//Class1 target = new Class1();
|
|
|
|
|
|
|
|
//Subject<bool> source1 = new Subject<bool>();
|
|
|
|
//Subject<bool> source2 = new Subject<bool>();
|
|
|
|
//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));
|
|
|
|
return Observable.Never<T>().StartWith(value); |
|
|
|
} |
|
|
|
|
|
|
|
private class Class1 : PerspexObject |
|
|
|
|