From fae9ea09d8de0019c1e80ab9d9ac740efa45c05c Mon Sep 17 00:00:00 2001 From: Artem Pushkin Date: Thu, 19 Oct 2023 23:21:24 +0100 Subject: [PATCH] Fixed tests. --- src/Hosting.Services/HostBuilderExtensions.cs | 2 +- src/Logging/ServiceCollectionExtensions.cs | 2 ++ tests/Activities.UnitTests/ServiceCollectionTests.cs | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Hosting.Services/HostBuilderExtensions.cs b/src/Hosting.Services/HostBuilderExtensions.cs index b02933a6..f568e86d 100644 --- a/src/Hosting.Services/HostBuilderExtensions.cs +++ b/src/Hosting.Services/HostBuilderExtensions.cs @@ -85,7 +85,6 @@ private static IHost BuildServiceFabricService( builderAction(new ServiceFabricHostBuilder(builder)); IHost host = builder - .ConfigureLogging(builder => builder.AddOmexLogging()) .ConfigureServices((context, collection) => { collection @@ -102,6 +101,7 @@ private static IHost BuildServiceFabricService( options.ValidateOnBuild = true; options.ValidateScopes = true; }) + .ConfigureLogging(builder => builder.AddOmexLogging()) .Build(); InitializationLogger.LogInitializationSucceed(serviceNameForLogging); diff --git a/src/Logging/ServiceCollectionExtensions.cs b/src/Logging/ServiceCollectionExtensions.cs index 884f7912..1543ee39 100644 --- a/src/Logging/ServiceCollectionExtensions.cs +++ b/src/Logging/ServiceCollectionExtensions.cs @@ -44,6 +44,8 @@ public static ILoggingBuilder AddOmexLogging(this ILoggingBuilder builder) /// The so that additional calls can be chained public static IServiceCollection AddOmexLogging(this IServiceCollection serviceCollection) { + serviceCollection.AddLogging(); + serviceCollection.TryAddTransient(); serviceCollection.TryAddTransient(); serviceCollection.TryAddTransient(); diff --git a/tests/Activities.UnitTests/ServiceCollectionTests.cs b/tests/Activities.UnitTests/ServiceCollectionTests.cs index 3f562694..b5cd0aa4 100644 --- a/tests/Activities.UnitTests/ServiceCollectionTests.cs +++ b/tests/Activities.UnitTests/ServiceCollectionTests.cs @@ -36,7 +36,6 @@ public void AddOmexActivitySource_HostedServicesRegistered() { Type[] types = GetRegisteredServices(); - Assert.AreEqual(2, types.Length); CollectionAssert.Contains(types, typeof(ActivityListenerInitializerService)); CollectionAssert.Contains(types, typeof(DiagnosticsObserversInitializer)); }