@@ -101,15 +101,15 @@ public void AddMonaiDeployStorageService_ConfiuresServicesAsExpected()
101
101
fileSystem . File . WriteAllBytes ( assemblyFilePath , assemblyData ) ;
102
102
var serviceCollection = new Mock < IServiceCollection > ( ) ;
103
103
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 ) ) ;
105
105
106
106
Assert . Null ( exception ) ;
107
107
108
108
serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
109
109
}
110
110
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 ( )
113
113
{
114
114
var goodType = typeof ( GoodStorageService ) ;
115
115
var typeName = goodType . AssemblyQualifiedName ;
@@ -123,14 +123,61 @@ public void AddMonaiDeployStorageService_ConfiuresServicesAndHealtChecksAsExpect
123
123
serviceCollection . Setup ( p => p . Clear ( ) ) ;
124
124
serviceCollection . Setup ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) ) ;
125
125
126
- var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , true ) ) ;
126
+ var exception = Record . Exception ( ( ) => serviceCollection . Object . AddMonaiDeployStorageService ( typeName , fileSystem , HealthCheckOptions . ServiceHealthCheck ) ) ;
127
127
128
128
Assert . Null ( exception ) ;
129
129
130
130
serviceCollection . Verify ( p => p . Clear ( ) , Times . Once ( ) ) ;
131
131
serviceCollection . Verify ( p => p . Add ( It . IsAny < ServiceDescriptor > ( ) ) , Times . Exactly ( 2 ) ) ;
132
132
}
133
133
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
+
134
181
private static byte [ ] GetAssemblyeBytes ( Assembly assembly )
135
182
{
136
183
return File . ReadAllBytes ( assembly . Location ) ;
@@ -139,10 +186,9 @@ private static byte[] GetAssemblyeBytes(Assembly assembly)
139
186
140
187
internal class TestHealthCheckRegistrar : HealthCheckRegistrationBase
141
188
{
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 ;
146
192
}
147
193
148
194
internal class TestServiceRegistrar : ServiceRegistrationBase
0 commit comments