Skip to content

Commit 18fe158

Browse files
Add VisualTree Tests
1 parent 1a87a35 commit 18fe158

File tree

3 files changed

+566
-0
lines changed

3 files changed

+566
-0
lines changed

UnitTests/UnitTests.UWP/Extensions/Test_LogicalTreeExtensions.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,45 @@ await App.DispatcherQueue.EnqueueAsync(async () =>
265265
});
266266
}
267267

268+
[TestCategory("LogicalTree")]
269+
[TestMethod]
270+
public async Task Test_LogicalTree_FindChildren_NotFound()
271+
{
272+
await App.DispatcherQueue.EnqueueAsync(async () =>
273+
{
274+
var treeRoot = XamlReader.Load(@"<Page
275+
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
276+
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> <!-- Starting Point -->
277+
<Grid>
278+
<Grid>
279+
<Border/>
280+
<TextBlock x:Name=""One""/>
281+
<StackPanel>
282+
<TextBox/>
283+
<TextBlock x:Name=""Two""/>
284+
</StackPanel>
285+
</Grid>
286+
<TextBlock x:Name=""Three""/>
287+
</Grid>
288+
</Page>") as Page;
289+
290+
// Test Setup
291+
Assert.IsNotNull(treeRoot, "XAML Failed to Load");
292+
293+
// Initialize Visual Tree
294+
await SetTestContentAsync(treeRoot);
295+
296+
// Main Test
297+
var thing = treeRoot.FindChildren<UniformGrid>();
298+
299+
Assert.IsNotNull(thing, "Expected to still have enumerable.");
300+
301+
var array = thing.ToArray();
302+
303+
Assert.AreEqual(0, array.Length, "Expected to have 0 elements.");
304+
});
305+
}
306+
268307
[TestCategory("LogicalTree")]
269308
[TestMethod]
270309
public async Task Test_LogicalTree_FindParent_Exists()

0 commit comments

Comments
 (0)