|
|
@ -14,23 +14,23 @@ using Xunit; |
|
|
|
|
|
|
|
|
namespace Avalonia.Styling.UnitTests |
|
|
namespace Avalonia.Styling.UnitTests |
|
|
{ |
|
|
{ |
|
|
public class SelectorTests_Descendent |
|
|
public class SelectorTests_Descendant |
|
|
{ |
|
|
{ |
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Descendent_Matches_Control_When_It_Is_Child_OfType() |
|
|
public void Descendant_Matches_Control_When_It_Is_Child_OfType() |
|
|
{ |
|
|
{ |
|
|
var parent = new TestLogical1(); |
|
|
var parent = new TestLogical1(); |
|
|
var child = new TestLogical2(); |
|
|
var child = new TestLogical2(); |
|
|
|
|
|
|
|
|
child.LogicalParent = parent; |
|
|
child.LogicalParent = parent; |
|
|
|
|
|
|
|
|
var selector = default(Selector).OfType<TestLogical1>().Descendent().OfType<TestLogical2>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Descendant().OfType<TestLogical2>(); |
|
|
|
|
|
|
|
|
Assert.True(selector.Match(child).ImmediateResult); |
|
|
Assert.True(selector.Match(child).ImmediateResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Descendent_Matches_Control_When_It_Is_Descendent_OfType() |
|
|
public void Descendant_Matches_Control_When_It_Is_Descendant_OfType() |
|
|
{ |
|
|
{ |
|
|
var grandparent = new TestLogical1(); |
|
|
var grandparent = new TestLogical1(); |
|
|
var parent = new TestLogical2(); |
|
|
var parent = new TestLogical2(); |
|
|
@ -39,13 +39,13 @@ namespace Avalonia.Styling.UnitTests |
|
|
parent.LogicalParent = grandparent; |
|
|
parent.LogicalParent = grandparent; |
|
|
child.LogicalParent = parent; |
|
|
child.LogicalParent = parent; |
|
|
|
|
|
|
|
|
var selector = default(Selector).OfType<TestLogical1>().Descendent().OfType<TestLogical3>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Descendant().OfType<TestLogical3>(); |
|
|
|
|
|
|
|
|
Assert.True(selector.Match(child).ImmediateResult); |
|
|
Assert.True(selector.Match(child).ImmediateResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Descendent_Matches_Control_When_It_Is_Descendent_OfType_And_Class() |
|
|
public async Task Descendant_Matches_Control_When_It_Is_Descendant_OfType_And_Class() |
|
|
{ |
|
|
{ |
|
|
var grandparent = new TestLogical1(); |
|
|
var grandparent = new TestLogical1(); |
|
|
var parent = new TestLogical2(); |
|
|
var parent = new TestLogical2(); |
|
|
@ -55,14 +55,14 @@ namespace Avalonia.Styling.UnitTests |
|
|
parent.LogicalParent = grandparent; |
|
|
parent.LogicalParent = grandparent; |
|
|
child.LogicalParent = parent; |
|
|
child.LogicalParent = parent; |
|
|
|
|
|
|
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendent().OfType<TestLogical3>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendant().OfType<TestLogical3>(); |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
|
|
|
|
|
|
Assert.True(await activator.Take(1)); |
|
|
Assert.True(await activator.Take(1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Descendent_Doesnt_Match_Control_When_It_Is_Descendent_OfType_But_Wrong_Class() |
|
|
public async Task Descendant_Doesnt_Match_Control_When_It_Is_Descendant_OfType_But_Wrong_Class() |
|
|
{ |
|
|
{ |
|
|
var grandparent = new TestLogical1(); |
|
|
var grandparent = new TestLogical1(); |
|
|
var parent = new TestLogical2(); |
|
|
var parent = new TestLogical2(); |
|
|
@ -73,14 +73,14 @@ namespace Avalonia.Styling.UnitTests |
|
|
parent.Classes.Add("foo"); |
|
|
parent.Classes.Add("foo"); |
|
|
child.LogicalParent = parent; |
|
|
child.LogicalParent = parent; |
|
|
|
|
|
|
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendent().OfType<TestLogical3>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendant().OfType<TestLogical3>(); |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
|
|
|
|
|
|
Assert.False(await activator.Take(1)); |
|
|
Assert.False(await activator.Take(1)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task Descendent_Matches_Any_Ancestor() |
|
|
public async Task Descendant_Matches_Any_Ancestor() |
|
|
{ |
|
|
{ |
|
|
var grandparent = new TestLogical1(); |
|
|
var grandparent = new TestLogical1(); |
|
|
var parent = new TestLogical1(); |
|
|
var parent = new TestLogical1(); |
|
|
@ -89,7 +89,7 @@ namespace Avalonia.Styling.UnitTests |
|
|
parent.LogicalParent = grandparent; |
|
|
parent.LogicalParent = grandparent; |
|
|
child.LogicalParent = parent; |
|
|
child.LogicalParent = parent; |
|
|
|
|
|
|
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendent().OfType<TestLogical3>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendant().OfType<TestLogical3>(); |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
var activator = selector.Match(child).ObservableResult; |
|
|
|
|
|
|
|
|
Assert.False(await activator.Take(1)); |
|
|
Assert.False(await activator.Take(1)); |
|
|
@ -104,9 +104,9 @@ namespace Avalonia.Styling.UnitTests |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void Descendent_Selector_Should_Have_Correct_String_Representation() |
|
|
public void Descendant_Selector_Should_Have_Correct_String_Representation() |
|
|
{ |
|
|
{ |
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendent().OfType<TestLogical3>(); |
|
|
var selector = default(Selector).OfType<TestLogical1>().Class("foo").Descendant().OfType<TestLogical3>(); |
|
|
|
|
|
|
|
|
Assert.Equal("TestLogical1.foo TestLogical3", selector.ToString()); |
|
|
Assert.Equal("TestLogical1.foo TestLogical3", selector.ToString()); |
|
|
} |
|
|
} |
|
|
|