@@ -101,15 +101,15 @@ public void AddMonaiDeployStorageService_ConfiuresServicesAsExpected()
101101 fileSystem . File . WriteAllBytes ( assemblyFilePath , assemblyData ) ;
102102 var serviceCollection = new Mock < IServiceCollection > ( ) ;
103103 serviceCollection . Setup ( p => p . Clear ( ) ) ;
104- var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , false ) ) ;
104+ var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , HealthCheckOptions . None ) ) ;
105105
106106 Assert . Null ( exception ) ;
107107
108108 serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
109109 }
110110
111- [ Fact ( DisplayName = "AddMonaiDeployStorageService configures all services & health checks as expected" ) ]
112- public void AddMonaiDeployStorageService_ConfiuresServicesAndHealtChecksAsExpected ( )
111+ [ Fact ( DisplayName = "AddMonaiDeployStorageService configures all services & service health check as expected" ) ]
112+ public void AddMonaiDeployStorageService_ConfiuresServicesAndServiceHealtCheckAsExpected ( )
113113 {
114114 var goodType = typeof ( GoodStorageService ) ;
115115 var typeName = goodType . AssemblyQualifiedName ;
@@ -123,14 +123,61 @@ public void AddMonaiDeployStorageService_ConfiuresServicesAndHealtChecksAsExpect
123123 serviceCollection . Setup ( p => p . Clear ( ) ) ;
124124 serviceCollection . Setup ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) ) ;
125125
126- var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , true ) ) ;
126+ var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , HealthCheckOptions . ServiceHealthCheck ) ) ;
127127
128128 Assert . Null ( exception ) ;
129129
130130 serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
131131 serviceCollection . Verify ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) , Times . Exactly ( 2 ) ) ;
132132 }
133133
134+ [ Fact ( DisplayName = "AddMonaiDeployStorageService configures all services & admin health check as expected" ) ]
135+ public void AddMonaiDeployStorageService_ConfiuresServicesAndAdminHealthCheckAsExpected ( )
136+ {
137+ var goodType = typeof ( GoodStorageService ) ;
138+ var typeName = goodType . AssemblyQualifiedName ;
139+ var assemblyData = GetAssemblyeBytes ( goodType . Assembly ) ;
140+ var assemblyFilePath = Path . Combine ( SR . PlugInDirectoryPath , goodType . Assembly . ManifestModule . Name ) ;
141+ var fileSystem = new MockFileSystem ( ) ;
142+ fileSystem . Directory . CreateDirectory ( SR . PlugInDirectoryPath ) ;
143+ fileSystem . File . WriteAllBytes ( assemblyFilePath , assemblyData ) ;
144+
145+ var serviceCollection = new Mock < IServiceCollection > ( ) ;
146+ serviceCollection . Setup ( p => p . Clear ( ) ) ;
147+ serviceCollection . Setup ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) ) ;
148+
149+ var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , HealthCheckOptions . AdminServiceHealthCheck ) ) ;
150+
151+ Assert . Null ( exception ) ;
152+
153+ serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
154+ serviceCollection . Verify ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) , Times . Exactly ( 2 ) ) ;
155+ }
156+
157+ [ Fact ( DisplayName = "AddMonaiDeployStorageService configures all services & all health checks as expected" ) ]
158+ public void AddMonaiDeployStorageService_ConfiuresServicesAndAllHealtCheckAsExpected ( )
159+ {
160+ var goodType = typeof ( GoodStorageService ) ;
161+ var typeName = goodType . AssemblyQualifiedName ;
162+ var assemblyData = GetAssemblyeBytes ( goodType . Assembly ) ;
163+ var assemblyFilePath = Path . Combine ( SR . PlugInDirectoryPath , goodType . Assembly . ManifestModule . Name ) ;
164+ var fileSystem = new MockFileSystem ( ) ;
165+ fileSystem . Directory . CreateDirectory ( SR . PlugInDirectoryPath ) ;
166+ fileSystem . File . WriteAllBytes ( assemblyFilePath , assemblyData ) ;
167+
168+ var serviceCollection = new Mock < IServiceCollection > ( ) ;
169+ serviceCollection . Setup ( p => p . Clear ( ) ) ;
170+ serviceCollection . Setup ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) ) ;
171+
172+ var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , HealthCheckOptions . ServiceHealthCheck | HealthCheckOptions . AdminServiceHealthCheck ) ) ;
173+
174+ Assert . Null ( exception ) ;
175+
176+ serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
177+ serviceCollection . Verify ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) , Times . Exactly ( 2 ) ) ;
178+ serviceCollection . Verify ( p => p . Add ( It . Is < ServiceDescriptor > ( p => p . ServiceType == typeof ( HealthCheckService ) ) ) , Times . Once ( ) ) ;
179+ }
180+
134181 private static byte [ ] GetAssemblyeBytes ( Assembly assembly )
135182 {
136183 return File . ReadAllBytes ( assembly . Location ) ;
@@ -139,10 +186,9 @@ private static byte[] GetAssemblyeBytes(Assembly assembly)
139186
140187 internal class TestHealthCheckRegistrar : HealthCheckRegistrationBase
141188 {
142- public override IHealthChecksBuilder Configure ( IHealthChecksBuilder builder , HealthStatus ? failureStatus = null , IEnumerable < string > ? tags = null , TimeSpan ? timeout = null )
143- {
144- return builder ;
145- }
189+ public override IHealthChecksBuilder ConfigureAdminHealthCheck ( IHealthChecksBuilder builder , HealthStatus ? failureStatus = null , IEnumerable < string > ? tags = null , TimeSpan ? timeout = null ) => builder ;
190+
191+ public override IHealthChecksBuilder ConfigureHealthCheck ( IHealthChecksBuilder builder , HealthStatus ? failureStatus = null , IEnumerable < string > ? tags = null , TimeSpan ? timeout = null ) => builder ;
146192 }
147193
148194 internal class TestServiceRegistrar : ServiceRegistrationBase
0 commit comments