public void UseEnrichers(LogLevel level, string message) { var dependencies = new DependencyCollection().AddLogs(); var enrichers = Many(() => new Mock <ILogEnricher>()); foreach (var enricher in enrichers) { dependencies.AddLogEnricher(enricher.Object); } dependencies .AddLogWriter(Mock.Of <ILogWriter>()) .BuildProvider() .GetRequired <ILogger <LogProviderShould> >() .Log(level, message); foreach (var enricher in enrichers) { enricher.Verify(e => e .Enrich(level, _sender, It.IsNotNull <JsonObject>())); } }
public void WriteWriters(LogLevel level, string message) { var dependencies = new DependencyCollection().AddLogs(); var writers = Many(() => new Mock <ILogWriter>()); foreach (var writer in writers) { dependencies.AddLogWriter(writer.Object); } dependencies.BuildProvider() .GetRequired <ILogger <LogProviderShould> >() .Log(level, message); foreach (var writer in writers) { writer.Verify(w => w .Write(It.Is <LogContext>(context => context.Level == level && context.Sender == _sender && context.Template == message), It.IsNotNull <JsonObject>())); } }