1
1
using CommunityToolkit . Maui . UnitTests . Mocks ;
2
+ using CommunityToolkit . Maui . UnitTests . Services ;
2
3
using Xunit ;
3
4
4
5
namespace CommunityToolkit . Maui . UnitTests . Extensions ;
@@ -7,7 +8,39 @@ public class ServiceCollectionExtensionsTests : BaseTest
7
8
{
8
9
const string customRoute = "//MockCustomRoute" ;
9
10
readonly Type mockPageType = typeof ( MockPage ) ;
10
- readonly Type mockPageViewModelType = typeof ( MockPageViewModel ) ;
11
+ readonly Type mockPopupType = typeof ( MockSelfClosingPopup ) ;
12
+ readonly Type mockViewModelType = typeof ( MockPageViewModel ) ;
13
+
14
+ [ Fact ]
15
+ public void IServiceCollection_VerifyTransientPopup ( )
16
+ {
17
+ // Arrange
18
+ var services = MauiApp . CreateBuilder ( ) . Services ;
19
+ const ServiceLifetime expectedServiceLifetime = ServiceLifetime . Transient ;
20
+
21
+ // Act
22
+ services . AddTransientPopup < MockSelfClosingPopup , MockPageViewModel > ( ) ;
23
+ var serviceProvider = services . BuildServiceProvider ( ) ;
24
+
25
+ // Assert
26
+ var mockPopupServiceDescriptor = services . Single ( s => s . ServiceType == mockPopupType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
27
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
28
+
29
+ Assert . NotNull ( mockPopupServiceDescriptor ) ;
30
+ Assert . NotNull ( mockViewModelServiceDescriptor ) ;
31
+
32
+ Assert . Equal ( expectedServiceLifetime , mockPopupServiceDescriptor . Lifetime ) ;
33
+ Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
34
+
35
+ Assert . Equal ( mockPopupType , mockPopupServiceDescriptor . ServiceType ) ;
36
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
37
+
38
+ Assert . Equal ( mockPopupType , mockPopupServiceDescriptor . ImplementationType ) ;
39
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
40
+
41
+ Assert . IsType < MockSelfClosingPopup > ( serviceProvider . GetRequiredService < MockSelfClosingPopup > ( ) ) ;
42
+ Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
43
+ }
11
44
12
45
[ Fact ]
13
46
public void IServiceCollection_VerifyTransient ( )
@@ -21,8 +54,8 @@ public void IServiceCollection_VerifyTransient()
21
54
var serviceProvider = services . BuildServiceProvider ( ) ;
22
55
23
56
// Assert
24
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
25
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
57
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
58
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
26
59
27
60
Assert . NotNull ( mockPageServiceDescriptor ) ;
28
61
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -31,10 +64,10 @@ public void IServiceCollection_VerifyTransient()
31
64
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
32
65
33
66
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
34
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
67
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
35
68
36
69
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
37
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
70
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
38
71
39
72
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
40
73
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -53,8 +86,8 @@ public void IServiceCollection_VerifyTransientShellRouteWithRouteParam()
53
86
var serviceProvider = services . BuildServiceProvider ( ) ;
54
87
55
88
// Assert
56
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
57
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
89
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
90
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
58
91
59
92
Assert . NotNull ( mockPageServiceDescriptor ) ;
60
93
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -65,10 +98,10 @@ public void IServiceCollection_VerifyTransientShellRouteWithRouteParam()
65
98
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
66
99
67
100
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
68
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
101
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
69
102
70
103
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
71
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
104
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
72
105
73
106
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
74
107
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -88,8 +121,8 @@ public void IServiceCollection_VerifyTransientShellRouteWithRouteAndRouteFactory
88
121
var serviceProvider = services . BuildServiceProvider ( ) ;
89
122
90
123
// Assert
91
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
92
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
124
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
125
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
93
126
94
127
Assert . NotNull ( mockPageServiceDescriptor ) ;
95
128
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -100,15 +133,46 @@ public void IServiceCollection_VerifyTransientShellRouteWithRouteAndRouteFactory
100
133
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
101
134
102
135
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
103
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
136
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
104
137
105
138
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
106
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
139
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
107
140
108
141
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
109
142
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
110
143
Assert . True ( factory . WasInvoked ) ;
111
144
}
145
+
146
+ [ Fact ]
147
+ public void IServiceCollection_VerifySingletonPopup ( )
148
+ {
149
+ // Arrange
150
+ const ServiceLifetime expectedServiceLifetime = ServiceLifetime . Singleton ;
151
+ var services = MauiApp . CreateBuilder ( ) . Services ;
152
+
153
+ // Act
154
+ services . AddSingletonPopup < MockSelfClosingPopup , MockPageViewModel > ( ) ;
155
+ var serviceProvider = services . BuildServiceProvider ( ) ;
156
+
157
+ // Assert
158
+ var mockPpopupServiceDescriptor = services . Single ( s => s . ServiceType == mockPopupType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
159
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
160
+
161
+ Assert . NotNull ( mockPpopupServiceDescriptor ) ;
162
+ Assert . NotNull ( mockViewModelServiceDescriptor ) ;
163
+
164
+ Assert . Equal ( expectedServiceLifetime , mockPpopupServiceDescriptor . Lifetime ) ;
165
+ Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
166
+
167
+ Assert . Equal ( mockPopupType , mockPpopupServiceDescriptor . ServiceType ) ;
168
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
169
+
170
+ Assert . Equal ( mockPopupType , mockPpopupServiceDescriptor . ImplementationType ) ;
171
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
172
+
173
+ Assert . IsType < MockSelfClosingPopup > ( serviceProvider . GetRequiredService < MockSelfClosingPopup > ( ) ) ;
174
+ Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
175
+ }
112
176
113
177
[ Fact ]
114
178
public void IServiceCollection_VerifySingleton ( )
@@ -122,8 +186,8 @@ public void IServiceCollection_VerifySingleton()
122
186
var serviceProvider = services . BuildServiceProvider ( ) ;
123
187
124
188
// Assert
125
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
126
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
189
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
190
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
127
191
128
192
Assert . NotNull ( mockPageServiceDescriptor ) ;
129
193
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -132,10 +196,10 @@ public void IServiceCollection_VerifySingleton()
132
196
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
133
197
134
198
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
135
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
199
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
136
200
137
201
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
138
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
202
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
139
203
140
204
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
141
205
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -154,8 +218,8 @@ public void IServiceCollection_VerifySingletonShellRouteWithRouteParam()
154
218
var serviceProvider = services . BuildServiceProvider ( ) ;
155
219
156
220
// Assert
157
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
158
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
221
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
222
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
159
223
160
224
Assert . NotNull ( mockPageServiceDescriptor ) ;
161
225
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -166,10 +230,10 @@ public void IServiceCollection_VerifySingletonShellRouteWithRouteParam()
166
230
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
167
231
168
232
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
169
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
233
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
170
234
171
235
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
172
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
236
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
173
237
174
238
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
175
239
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -189,8 +253,8 @@ public void IServiceCollection_VerifySingletonShellRouteWithRouteAndRouteFactory
189
253
var serviceProvider = services . BuildServiceProvider ( ) ;
190
254
191
255
// Assert
192
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
193
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
256
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
257
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
194
258
195
259
Assert . NotNull ( mockPageServiceDescriptor ) ;
196
260
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -201,16 +265,47 @@ public void IServiceCollection_VerifySingletonShellRouteWithRouteAndRouteFactory
201
265
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
202
266
203
267
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
204
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
268
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
205
269
206
270
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
207
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
271
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
208
272
209
273
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
210
274
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
211
275
212
276
Assert . True ( factory . WasInvoked ) ;
213
277
}
278
+
279
+ [ Fact ]
280
+ public void IServiceCollection_VerifyScopedPopup ( )
281
+ {
282
+ // Arrange
283
+ const ServiceLifetime expectedServiceLifetime = ServiceLifetime . Scoped ;
284
+ var services = MauiApp . CreateBuilder ( ) . Services ;
285
+
286
+ // Act
287
+ services . AddScopedPopup < MockSelfClosingPopup , MockPageViewModel > ( ) ;
288
+ var serviceProvider = services . BuildServiceProvider ( ) ;
289
+
290
+ // Assert
291
+ var mockPopupServiceDescriptor = services . Single ( s => s . ServiceType == mockPopupType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
292
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
293
+
294
+ Assert . NotNull ( mockPopupServiceDescriptor ) ;
295
+ Assert . NotNull ( mockViewModelServiceDescriptor ) ;
296
+
297
+ Assert . Equal ( expectedServiceLifetime , mockPopupServiceDescriptor . Lifetime ) ;
298
+ Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
299
+
300
+ Assert . Equal ( mockPopupType , mockPopupServiceDescriptor . ServiceType ) ;
301
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
302
+
303
+ Assert . Equal ( mockPopupType , mockPopupServiceDescriptor . ImplementationType ) ;
304
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
305
+
306
+ Assert . IsType < MockSelfClosingPopup > ( serviceProvider . GetRequiredService < MockSelfClosingPopup > ( ) ) ;
307
+ Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
308
+ }
214
309
215
310
[ Fact ]
216
311
public void IServiceCollection_VerifyScoped ( )
@@ -224,8 +319,8 @@ public void IServiceCollection_VerifyScoped()
224
319
var serviceProvider = services . BuildServiceProvider ( ) ;
225
320
226
321
// Assert
227
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
228
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
322
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
323
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
229
324
230
325
Assert . NotNull ( mockPageServiceDescriptor ) ;
231
326
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -234,10 +329,10 @@ public void IServiceCollection_VerifyScoped()
234
329
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
235
330
236
331
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
237
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
332
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
238
333
239
334
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
240
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
335
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
241
336
242
337
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
243
338
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -256,8 +351,8 @@ public void IServiceCollection_VerifyScopedShellRouteWithRouteParam()
256
351
var serviceProvider = services . BuildServiceProvider ( ) ;
257
352
258
353
// Assert
259
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
260
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
354
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
355
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
261
356
262
357
Assert . NotNull ( mockPageServiceDescriptor ) ;
263
358
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -268,10 +363,10 @@ public void IServiceCollection_VerifyScopedShellRouteWithRouteParam()
268
363
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
269
364
270
365
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
271
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
366
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
272
367
273
368
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
274
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
369
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
275
370
276
371
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
277
372
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
@@ -291,8 +386,8 @@ public void IServiceCollection_VerifyScopedShellRouteWithRouteAndRouteFactoryPar
291
386
var serviceProvider = services . BuildServiceProvider ( ) ;
292
387
293
388
// Assert
294
- var mockPageServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
295
- var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType . Equals ( mockPageViewModelType ) && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
389
+ var mockPageServiceDescriptor = services . Single ( s => s . ServiceType == mockPageType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
390
+ var mockViewModelServiceDescriptor = services . Single ( s => s . ServiceType == mockViewModelType && s . Lifetime . Equals ( expectedServiceLifetime ) ) ;
296
391
297
392
Assert . NotNull ( mockPageServiceDescriptor ) ;
298
393
Assert . NotNull ( mockViewModelServiceDescriptor ) ;
@@ -303,10 +398,10 @@ public void IServiceCollection_VerifyScopedShellRouteWithRouteAndRouteFactoryPar
303
398
Assert . Equal ( expectedServiceLifetime , mockViewModelServiceDescriptor . Lifetime ) ;
304
399
305
400
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ServiceType ) ;
306
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
401
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ServiceType ) ;
307
402
308
403
Assert . Equal ( mockPageType , mockPageServiceDescriptor . ImplementationType ) ;
309
- Assert . Equal ( mockPageViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
404
+ Assert . Equal ( mockViewModelType , mockViewModelServiceDescriptor . ImplementationType ) ;
310
405
311
406
Assert . IsType < MockPage > ( serviceProvider . GetRequiredService < MockPage > ( ) ) ;
312
407
Assert . IsType < MockPageViewModel > ( serviceProvider . GetRequiredService < MockPageViewModel > ( ) ) ;
0 commit comments