diff --git a/Snittlistan.Test/Domain/MatchResult_MatchCommentary.cs b/Snittlistan.Test/Domain/MatchResult_MatchCommentary.cs index 2ca29492..802cd45b 100644 --- a/Snittlistan.Test/Domain/MatchResult_MatchCommentary.cs +++ b/Snittlistan.Test/Domain/MatchResult_MatchCommentary.cs @@ -1,5 +1,6 @@ #nullable enable +using Castle.Core.Logging; using EventStoreLite; using Moq; using NUnit.Framework; @@ -173,7 +174,8 @@ await Transact(async session => Container.Resolve(), CurrentTenant, Container.Resolve(), - Mock.Of(MockBehavior.Strict)); + Mock.Of(MockBehavior.Strict), + NullLogger.Instance); CommandExecutor commandExecutor = new( compositionRoot, Databases, diff --git a/Snittlistan.Web/Infrastructure/CompositionRoot.cs b/Snittlistan.Web/Infrastructure/CompositionRoot.cs index e64686b5..67f6863d 100644 --- a/Snittlistan.Web/Infrastructure/CompositionRoot.cs +++ b/Snittlistan.Web/Infrastructure/CompositionRoot.cs @@ -1,5 +1,6 @@ #nullable enable +using Castle.Core.Logging; using Castle.MicroKernel; using EventStoreLite; using Postal; @@ -20,7 +21,8 @@ public record CompositionRoot( EventStore EventStore, Tenant CurrentTenant, IEmailService EmailService, - IBitsClient BitsClient) + IBitsClient BitsClient, + ILogger Logger) { public Guid CorrelationId { @@ -42,7 +44,23 @@ public async Task GetFeatures() KeyValueProperty? settingsProperty = await Databases.Snittlistan.KeyValueProperties.SingleOrDefaultAsync( x => x.Key == TenantFeatures.Key && x.TenantId == CurrentTenant.TenantId); - return settingsProperty?.Value as TenantFeatures - ?? TenantFeatures.Default; + do + { + if (settingsProperty is null) + { + Logger.Info("no tenant features found"); + break; + } + + if (settingsProperty.Value is TenantFeatures tenantFeatures) + { + Logger.InfoFormat("found tenant features {@tenantFeatures}", tenantFeatures); + return tenantFeatures; + } + } + while (false); + + Logger.Warn("no tenant features found, or unusable"); + return TenantFeatures.Default; } }