|
|
|
@ -24,7 +24,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target); |
|
|
|
style.Attach(target, null); |
|
|
|
|
|
|
|
Assert.Equal("Foo", target.Foo); |
|
|
|
} |
|
|
|
@ -42,7 +42,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target); |
|
|
|
style.Attach(target, null); |
|
|
|
Assert.Equal("foodefault", target.Foo); |
|
|
|
target.Classes.Add("foo"); |
|
|
|
Assert.Equal("Foo", target.Foo); |
|
|
|
@ -50,6 +50,43 @@ namespace Perspex.Styling.UnitTests |
|
|
|
Assert.Equal("foodefault", target.Foo); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Style_With_No_Selector_Should_Apply_To_Containing_Control() |
|
|
|
{ |
|
|
|
Style style = new Style |
|
|
|
{ |
|
|
|
Setters = new[] |
|
|
|
{ |
|
|
|
new Setter(Class1.FooProperty, "Foo"), |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target, target); |
|
|
|
|
|
|
|
Assert.Equal("Foo", target.Foo); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Style_With_No_Selector_Should_Not_Apply_To_Other_Control() |
|
|
|
{ |
|
|
|
Style style = new Style |
|
|
|
{ |
|
|
|
Setters = new[] |
|
|
|
{ |
|
|
|
new Setter(Class1.FooProperty, "Foo"), |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
var other = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target, other); |
|
|
|
|
|
|
|
Assert.Equal("foodefault", target.Foo); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void LocalValue_Should_Override_Style() |
|
|
|
{ |
|
|
|
@ -66,7 +103,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
Foo = "Original", |
|
|
|
}; |
|
|
|
|
|
|
|
style.Attach(target); |
|
|
|
style.Attach(target, null); |
|
|
|
Assert.Equal("Original", target.Foo); |
|
|
|
} |
|
|
|
|
|
|
|
@ -97,7 +134,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
List<string> values = new List<string>(); |
|
|
|
target.GetObservable(Class1.FooProperty).Subscribe(x => values.Add(x)); |
|
|
|
|
|
|
|
styles.Attach(target); |
|
|
|
styles.Attach(target, null); |
|
|
|
target.Classes.Add("foo"); |
|
|
|
target.Classes.Remove("foo"); |
|
|
|
|
|
|
|
@ -119,7 +156,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target); |
|
|
|
style.Attach(target, null); |
|
|
|
|
|
|
|
Assert.Equal("Foo", target.Foo); |
|
|
|
} |
|
|
|
@ -139,7 +176,7 @@ namespace Perspex.Styling.UnitTests |
|
|
|
|
|
|
|
var target = new Class1(); |
|
|
|
|
|
|
|
style.Attach(target); |
|
|
|
style.Attach(target, null); |
|
|
|
|
|
|
|
Assert.Equal("foodefault", target.Foo); |
|
|
|
target.Classes.Add("foo"); |
|
|
|
|