15
15
*/
16
16
17
17
using System ;
18
+ using System . Collections . Generic ;
19
+ using DotNext . Collections . Generic ;
20
+ using Microsoft . Extensions . DependencyInjection ;
21
+ using Microsoft . Extensions . Hosting ;
18
22
using Monai . Deploy . InformaticsGateway . Api . Rest ;
19
23
using Monai . Deploy . InformaticsGateway . Repositories ;
20
24
using Monai . Deploy . InformaticsGateway . Services . Common ;
@@ -37,26 +41,32 @@ public MonaiServiceLocatorTest()
37
41
mock . SetupGet ( p => p . ServiceName ) . Returns ( type . Name ) ;
38
42
return mock . Object ;
39
43
} ) ;
44
+
45
+ _serviceProvider . Setup ( sp => sp . GetService ( typeof ( IEnumerable < IHostedService > ) ) )
46
+ . Returns ( ( Type type ) =>
47
+ {
48
+ var mock = new Mock < IHostedService > ( ) ;
49
+ return new List < IHostedService > { mock . Object } ;
50
+ } ) ;
40
51
}
41
52
42
53
[ Fact ( DisplayName = "GetMonaiServices" ) ]
43
54
public void GetMonaiServices ( )
44
55
{
56
+ var hosted = new List < IHostedService > ( )
57
+ {
58
+ new Mock < IHostedService > ( ) . Object
59
+ } ;
60
+
61
+
62
+
45
63
var serviceLocator = new MonaiServiceLocator ( _serviceProvider . Object ) ;
46
64
var result = serviceLocator . GetMonaiServices ( ) ;
47
65
48
66
Assert . Collection ( result ,
49
- items => items . ServiceName . Equals ( "DataRetrievalService" ) ,
50
- items => items . ServiceName . Equals ( "ScpService" ) ,
51
- items => items . ServiceName . Equals ( "ScuService" ) ,
52
- items => items . ServiceName . Equals ( "ExtAppScuService" ) ,
53
- items => items . ServiceName . Equals ( "SpaceReclaimerService" ) ,
54
- items => items . ServiceName . Equals ( "DicomWebExportService" ) ,
55
- items => items . ServiceName . Equals ( "ScuExportService" ) ,
56
- items => items . ServiceName . Equals ( "PayloadNotificationService" ) ,
57
- items => items . ServiceName . Equals ( "HL7 Service" ) ,
58
- items => items . ServiceName . Equals ( "ExtAppScuExportService" ) ,
59
- items => items . ServiceName . Equals ( "Hl7ExportService" ) ) ;
67
+ items => items . ServiceName . Equals ( "IMllpService" ) ,
68
+ items => items . ServiceName . Equals ( "IPayloadService" ) ) ;
69
+
60
70
}
61
71
62
72
[ Fact ( DisplayName = "GetServiceStatus" ) ]
@@ -65,7 +75,7 @@ public void GetServiceStatus()
65
75
var serviceLocator = new MonaiServiceLocator ( _serviceProvider . Object ) ;
66
76
var result = serviceLocator . GetServiceStatus ( ) ;
67
77
68
- Assert . Equal ( 11 , result . Count ) ;
78
+ Assert . Equal ( 2 , result . Count ) ;
69
79
foreach ( var svc in result . Keys )
70
80
{
71
81
Assert . Equal ( ServiceStatus . Running , result [ svc ] ) ;
0 commit comments