@@ -10,95 +10,13 @@ namespace HeaderedControls.Tests;
10
10
[ TestClass ]
11
11
public partial class HeaderedContentControlTestClass : VisualUITestBase
12
12
{
13
- // If you don't need access to UI objects directly or async code, use this pattern.
14
- [ TestMethod ]
15
- public void SimpleSynchronousExampleTest ( )
16
- {
17
- var assembly = typeof ( HeaderedContentControl ) . Assembly ;
18
- var type = assembly . GetType ( typeof ( HeaderedContentControl ) . FullName ?? string . Empty ) ;
19
-
20
- Assert . IsNotNull ( type , "Could not find HeaderedContentControl type." ) ;
21
- Assert . AreEqual ( typeof ( HeaderedContentControl ) , type , "Type of HeaderedContentControl does not match expected type." ) ;
22
- }
23
-
24
13
// The UIThreadTestMethod can also easily grab a XAML Page for us by passing its type as a parameter.
25
14
// This lets us actually test a control as it would behave within an actual application.
26
15
// The page will already be loaded by the time your test is called.
27
16
[ UIThreadTestMethod ]
28
17
public void SimpleUIExamplePageTest ( HeaderedContentControlTestPage page )
29
18
{
30
- // You can use the Toolkit Visual Tree helpers here to find the component by type or name:
31
- var component = page . FindDescendant < HeaderedContentControl > ( ) ;
32
-
33
- Assert . IsNotNull ( component ) ;
34
-
35
- var componentByName = page . FindDescendant ( "HeaderedContentControl" ) ;
36
-
37
- Assert . IsNotNull ( componentByName ) ;
38
- }
39
-
40
- // You can still do async work with a UIThreadTestMethod as well.
41
- [ UIThreadTestMethod ]
42
- public async Task SimpleAsyncUIExamplePageTest ( HeaderedContentControlTestPage page )
43
- {
44
- // This helper can be used to wait for a rendering pass to complete.
45
- await CompositionTargetHelper . ExecuteAfterCompositionRenderingAsync ( ( ) => { } ) ;
46
-
47
19
var component = page . FindDescendant < HeaderedContentControl > ( ) ;
48
-
49
20
Assert . IsNotNull ( component ) ;
50
21
}
51
-
52
- //// ----------------------------- ADVANCED TEST SCENARIOS -----------------------------
53
-
54
- // If you need to use DataRow, you can use this pattern with the UI dispatch still.
55
- // Otherwise, checkout the UIThreadTestMethod attribute above.
56
- // See https://github.com/CommunityToolkit/Labs-Windows/issues/186
57
- [ TestMethod ]
58
- public async Task ComplexAsyncUIExampleTest ( )
59
- {
60
- await EnqueueAsync ( ( ) =>
61
- {
62
- var component = new HeaderedContentControl ( ) ;
63
- Assert . IsNotNull ( component ) ;
64
- } ) ;
65
- }
66
-
67
- // If you want to load other content not within a XAML page using the UIThreadTestMethod above.
68
- // Then you can do that using the Load/UnloadTestContentAsync methods.
69
- [ TestMethod ]
70
- public async Task ComplexAsyncLoadUIExampleTest ( )
71
- {
72
- await EnqueueAsync ( async ( ) =>
73
- {
74
- var component = new HeaderedContentControl ( ) ;
75
- Assert . IsNotNull ( component ) ;
76
- Assert . IsFalse ( component . IsLoaded ) ;
77
-
78
- await LoadTestContentAsync ( component ) ;
79
-
80
- Assert . IsTrue ( component . IsLoaded ) ;
81
-
82
- await UnloadTestContentAsync ( component ) ;
83
-
84
- Assert . IsFalse ( component . IsLoaded ) ;
85
- } ) ;
86
- }
87
-
88
- // You can still use the UIThreadTestMethod to remove the extra layer for the dispatcher as well:
89
- [ UIThreadTestMethod ]
90
- public async Task ComplexAsyncLoadUIExampleWithoutDispatcherTest ( )
91
- {
92
- var component = new HeaderedContentControl ( ) ;
93
- Assert . IsNotNull ( component ) ;
94
- Assert . IsFalse ( component . IsLoaded ) ;
95
-
96
- await LoadTestContentAsync ( component ) ;
97
-
98
- Assert . IsTrue ( component . IsLoaded ) ;
99
-
100
- await UnloadTestContentAsync ( component ) ;
101
-
102
- Assert . IsFalse ( component . IsLoaded ) ;
103
- }
104
22
}
0 commit comments