[Fact] // see: https://github.com/dotnet/extensions/issues/639 public void AddHealthChecks_RegistersPublisherService_WhenOtherHostedServicesRegistered() { // Arrange var services = new ServiceCollection(); // Act services.AddSingleton <IHostedService, DummyHostedService>(); services.AddHealthChecks(); // Assert Assert.Collection(services.OrderBy(s => s.ServiceType.FullName).ThenBy(s => s.ImplementationType.FullName), actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); Assert.Equal(typeof(HealthCheckService), actual.ServiceType); Assert.Equal(typeof(DefaultHealthCheckService), actual.ImplementationType); Assert.Null(actual.ImplementationInstance); Assert.Null(actual.ImplementationFactory); }, actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); Assert.Equal(typeof(IHostedService), actual.ServiceType); Assert.Equal(typeof(DummyHostedService), actual.ImplementationType); Assert.Null(actual.ImplementationInstance); Assert.Null(actual.ImplementationFactory); }, actual => { Assert.Equal(ServiceLifetime.Singleton, actual.Lifetime); Assert.Equal(typeof(IHostedService), actual.ServiceType); Assert.Equal(typeof(HealthCheckPublisherHostedService), actual.ImplementationType); Assert.Null(actual.ImplementationInstance); Assert.Null(actual.ImplementationFactory); }); }