public void LocalValue_Should_Override_Style() { Style style = new Style(x => x.OfType<Class1>()) { Setters = new[] { new Setter(Class1.FooProperty, "Foo"), }, }; var target = new Class1 { Foo = "Original", }; style.Attach(target); Assert.Equal("Original", target.Foo); }
public void Style_With_Only_Type_Selector_Should_Update_Value() { Style style = new Style(x => x.OfType<Class1>()) { Setters = new[] { new Setter(Class1.FooProperty, "Foo"), }, }; var target = new Class1(); style.Attach(target); Assert.Equal("Foo", target.Foo); }
public void Style_With_Class_Selector_Should_Update_And_Restore_Value() { Style style = new Style(x => x.OfType<Class1>().Class("foo")) { Setters = new[] { new Setter(Class1.FooProperty, "Foo"), }, }; var target = new Class1(); style.Attach(target); Assert.Equal("foodefault", target.Foo); target.Classes.Add("foo"); Assert.Equal("Foo", target.Foo); target.Classes.Remove("foo"); Assert.Equal("foodefault", target.Foo); }
public void Style_With_Value_And_Source_Should_Throw_Exception() { var source = new BehaviorSubject<string>("Foo"); Style style = new Style(x => x.OfType<Class1>()) { Setters = new[] { new Setter { Property = Class1.FooProperty, Source = source, Value = "Foo", }, }, }; var target = new Class1(); Assert.Throws<InvalidOperationException>(() => style.Attach(target)); }
public void Style_With_Source_Should_Update_Value() { var source = new BehaviorSubject<string>("Foo"); Style style = new Style(x => x.OfType<Class1>()) { Setters = new[] { new Setter(Class1.FooProperty, source), }, }; var target = new Class1(); style.Attach(target); Assert.Equal("Foo", target.Foo); source.OnNext("Bar"); Assert.Equal("Bar", target.Foo); }