33// See the LICENSE file in the project root for more information.
44
55using System ;
6- using System . Diagnostics . CodeAnalysis ;
76using Microsoft . VisualStudio . TestTools . UnitTesting ;
87using Microsoft . VisualStudio . TestTools . UnitTesting . AppContainer ;
98using System . Linq ;
109using System . Threading . Tasks ;
1110using Windows . UI . Xaml . Controls ;
12- using Microsoft . Toolkit . Uwp . Helpers ;
1311using Windows . ApplicationModel . Core ;
1412using Windows . UI . Core ;
1513using Windows . System ;
1614using Microsoft . Toolkit . Uwp . Extensions ;
1715
18- namespace UnitTests . Helpers
16+ namespace UnitTests . Extensions
1917{
2018 [ TestClass ]
2119 [ Ignore ( "Ignored until issue on .Net Native is fixed. These are working." ) ]
22- public class Test_DispatcherQueueHelper
20+ public class Test_DispatcherQueueExtensions
2321 {
2422 private const int TIME_OUT = 5000 ;
2523
26- [ TestCategory ( "Helpers " ) ]
24+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
2725 [ UITestMethod ]
28- [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
26+ [ ExpectedException ( typeof ( NullReferenceException ) ) ]
2927 public void Test_DispatcherQueueHelper_Action_Null ( )
3028 {
31- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , default ( Action ) ) ;
29+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( default ( Action ) ! ) ;
3230 }
3331
34- [ TestCategory ( "Helpers " ) ]
32+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
3533 [ UITestMethod ]
3634 public void Test_DispatcherQueueHelper_Action_Ok_UIThread ( )
3735 {
38- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , ( ) =>
36+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( ( ) =>
3937 {
4038 var textBlock = new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_Action_Ok_UIThread ) } ;
4139
4240 Assert . AreEqual ( textBlock . Text , nameof ( Test_DispatcherQueueHelper_Action_Ok_UIThread ) ) ;
4341 } ) . Wait ( ) ;
4442 }
4543
46- [ TestCategory ( "Helpers " ) ]
44+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
4745 [ TestMethod ]
4846 public async Task Test_DispatcherQueueHelper_Action_Ok_NonUIThread ( )
4947 {
@@ -56,7 +54,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
5654 var dispatcherQueue = DispatcherQueue . GetForCurrentThread ( ) ;
5755 await Task . Run ( async ( ) =>
5856 {
59- await DispatcherQueueExtensions . EnqueueAsync ( dispatcherQueue , ( ) =>
57+ await dispatcherQueue . EnqueueAsync ( ( ) =>
6058 {
6159 var textBlock = new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_Action_Ok_NonUIThread ) } ;
6260
@@ -74,11 +72,11 @@ await DispatcherQueueExtensions.EnqueueAsync(dispatcherQueue, () =>
7472 await taskSource . Task ;
7573 }
7674
77- [ TestCategory ( "Helpers " ) ]
75+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
7876 [ UITestMethod ]
7977 public void Test_DispatcherQueueHelper_Action_Exception ( )
8078 {
81- var task = DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , ( ) =>
79+ var task = DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( ( ) =>
8280 {
8381 throw new ArgumentException ( nameof ( this . Test_DispatcherQueueHelper_Action_Exception ) ) ;
8482 } ) ;
@@ -89,27 +87,27 @@ public void Test_DispatcherQueueHelper_Action_Exception()
8987 Assert . IsInstanceOfType ( task . Exception . InnerExceptions . FirstOrDefault ( ) , typeof ( ArgumentException ) ) ;
9088 }
9189
92- [ TestCategory ( "Helpers " ) ]
90+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
9391 [ UITestMethod ]
94- [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
92+ [ ExpectedException ( typeof ( NullReferenceException ) ) ]
9593 public void Test_DispatcherQueueHelper_FuncOfT_Null ( )
9694 {
97- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , default ( Func < int > ) ) ;
95+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( default ( Func < int > ) ! ) ;
9896 }
9997
100- [ TestCategory ( "Helpers " ) ]
98+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
10199 [ UITestMethod ]
102100 public void Test_DispatcherQueueHelper_FuncOfT_Ok_UIThread ( )
103101 {
104- var textBlock = DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , ( ) =>
102+ var textBlock = DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( ( ) =>
105103 {
106104 return new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_FuncOfT_Ok_UIThread ) } ;
107105 } ) . Result ;
108106
109107 Assert . AreEqual ( textBlock . Text , nameof ( Test_DispatcherQueueHelper_FuncOfT_Ok_UIThread ) ) ;
110108 }
111109
112- [ TestCategory ( "Helpers " ) ]
110+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
113111 [ TestMethod ]
114112 public async Task Test_DispatcherQueueHelper_FuncOfT_Ok_NonUIThread ( )
115113 {
@@ -122,11 +120,11 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
122120 var dispatcherQueue = DispatcherQueue . GetForCurrentThread ( ) ;
123121 await Task . Run ( async ( ) =>
124122 {
125- var textBlock = await DispatcherQueueExtensions . EnqueueAsync ( dispatcherQueue , ( ) =>
123+ var textBlock = await dispatcherQueue . EnqueueAsync ( ( ) =>
126124 {
127125 return new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_FuncOfT_Ok_NonUIThread ) } ;
128126 } ) ;
129- await DispatcherQueueExtensions . EnqueueAsync ( dispatcherQueue , ( ) =>
127+ await dispatcherQueue . EnqueueAsync ( ( ) =>
130128 {
131129 Assert . AreEqual ( textBlock . Text , nameof ( Test_DispatcherQueueHelper_FuncOfT_Ok_NonUIThread ) ) ;
132130 taskSource . SetResult ( null ) ;
@@ -141,11 +139,11 @@ await DispatcherQueueExtensions.EnqueueAsync(dispatcherQueue, () =>
141139 await taskSource . Task ;
142140 }
143141
144- [ TestCategory ( "Helpers " ) ]
142+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
145143 [ UITestMethod ]
146144 public void Test_DispatcherQueueHelper_FuncOfT_Exception ( )
147145 {
148- var task = DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , new Func < int > ( ( ) =>
146+ var task = DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( new Func < int > ( ( ) =>
149147 {
150148 throw new ArgumentException ( nameof ( this . Test_DispatcherQueueHelper_FuncOfT_Exception ) ) ;
151149 } ) ) ;
@@ -156,20 +154,19 @@ public void Test_DispatcherQueueHelper_FuncOfT_Exception()
156154 Assert . IsInstanceOfType ( task . Exception . InnerExceptions . FirstOrDefault ( ) , typeof ( ArgumentException ) ) ;
157155 }
158156
159- [ TestCategory ( "Helpers " ) ]
157+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
160158 [ UITestMethod ]
161- [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
162- [ SuppressMessage ( "Style" , "IDE0034" , Justification = "Explicit overload for clarity" ) ]
159+ [ ExpectedException ( typeof ( NullReferenceException ) ) ]
163160 public void Test_DispatcherQueueHelper_FuncOfTask_Null ( )
164161 {
165- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , default ( Func < Task > ) ) ;
162+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( default ( Func < Task > ) ! ) ;
166163 }
167164
168165 [ TestCategory ( "Helpers" ) ]
169166 [ UITestMethod ]
170167 public void Test_DispatcherQueueHelper_FuncOfTask_Ok_UIThread ( )
171168 {
172- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , ( ) =>
169+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( ( ) =>
173170 {
174171 var textBlock = new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_FuncOfTask_Ok_UIThread ) } ;
175172
@@ -179,7 +176,7 @@ public void Test_DispatcherQueueHelper_FuncOfTask_Ok_UIThread()
179176 } ) . Wait ( ) ;
180177 }
181178
182- [ TestCategory ( "Helpers " ) ]
179+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
183180 [ TestMethod ]
184181 public async Task Test_DispatcherQueueHelper_FuncOfTask_Ok_NonUIThread ( )
185182 {
@@ -189,7 +186,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
189186 {
190187 try
191188 {
192- await DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , async ( ) =>
189+ await DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( async ( ) =>
193190 {
194191 await Task . Yield ( ) ;
195192
@@ -208,11 +205,11 @@ await DispatcherQueueExtensions.EnqueueAsync(DispatcherQueue.GetForCurrentThread
208205 await taskSource . Task ;
209206 }
210207
211- [ TestCategory ( "Helpers " ) ]
208+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
212209 [ UITestMethod ]
213210 public void Test_DispatcherQueueHelper_FuncOfTask_Exception ( )
214211 {
215- var task = DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , new Func < Task > ( ( ) =>
212+ var task = DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( new Func < Task > ( ( ) =>
216213 {
217214 throw new ArgumentException ( nameof ( this . Test_DispatcherQueueHelper_FuncOfTask_Exception ) ) ;
218215 } ) ) ;
@@ -223,19 +220,19 @@ public void Test_DispatcherQueueHelper_FuncOfTask_Exception()
223220 Assert . IsInstanceOfType ( task . Exception . InnerExceptions . FirstOrDefault ( ) , typeof ( ArgumentException ) ) ;
224221 }
225222
226- [ TestCategory ( "Helpers " ) ]
223+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
227224 [ UITestMethod ]
228- [ ExpectedException ( typeof ( ArgumentNullException ) ) ]
225+ [ ExpectedException ( typeof ( NullReferenceException ) ) ]
229226 public void Test_DispatcherQueueHelper_FuncOfTaskOfT_Null ( )
230227 {
231- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , default ( Func < Task < int > > ) ) ;
228+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( default ( Func < Task < int > > ) ! ) ;
232229 }
233230
234- [ TestCategory ( "Helpers " ) ]
231+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
235232 [ UITestMethod ]
236233 public void Test_DispatcherQueueHelper_FuncOfTaskOfT_Ok_UIThread ( )
237234 {
238- DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , ( ) =>
235+ DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( ( ) =>
239236 {
240237 var textBlock = new TextBlock { Text = nameof ( Test_DispatcherQueueHelper_FuncOfTaskOfT_Ok_UIThread ) } ;
241238
@@ -245,7 +242,7 @@ public void Test_DispatcherQueueHelper_FuncOfTaskOfT_Ok_UIThread()
245242 } ) . Wait ( ) ;
246243 }
247244
248- [ TestCategory ( "Helpers " ) ]
245+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
249246 [ TestMethod ]
250247 public async Task Test_DispatcherQueueHelper_FuncOfTaskOfT_Ok_NonUIThread ( )
251248 {
@@ -255,7 +252,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
255252 {
256253 try
257254 {
258- await DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , async ( ) =>
255+ await DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( async ( ) =>
259256 {
260257 await Task . Yield ( ) ;
261258
@@ -276,11 +273,11 @@ await DispatcherQueueExtensions.EnqueueAsync(DispatcherQueue.GetForCurrentThread
276273 await taskSource . Task ;
277274 }
278275
279- [ TestCategory ( "Helpers " ) ]
276+ [ TestCategory ( "DispatcherQueueExtensions " ) ]
280277 [ UITestMethod ]
281278 public void Test_DispatcherQueueHelper_FuncOfTaskOfT_Exception ( )
282279 {
283- var task = DispatcherQueueExtensions . EnqueueAsync ( DispatcherQueue . GetForCurrentThread ( ) , new Func < Task < int > > ( ( ) =>
280+ var task = DispatcherQueue . GetForCurrentThread ( ) . EnqueueAsync ( new Func < Task < int > > ( ( ) =>
284281 {
285282 throw new ArgumentException ( nameof ( this . Test_DispatcherQueueHelper_FuncOfTaskOfT_Exception ) ) ;
286283 } ) ) ;
0 commit comments