public void Log_WithSimpleMicrosoftLoggerScope_LogsValidEvent()
        {
            const string scope            = "s1";
            var          expectedLogEvent = new VostokLogEvent(LogLevel.Info, DateTimeOffset.Now, "message")
                                            .WithProperty("operationContext", new OperationContextValue(scope));

            using (microsoftLogger.BeginScope(scope))
            {
                microsoftLog.Info("message");

                oracleLog.Events.Single()
                .Should()
                .BeEquivalentTo(expectedLogEvent, o => o.Excluding(x => x.Timestamp));
            }
        }
Exemple #2
0
        public void Log_WithException_LogsValidEvent()
        {
            var exception        = new Exception("exception");
            var expectedLogEvent = new MicrosoftMemoryLoggerEvent
            {
                Category  = TestCategoryName,
                LogLevel  = MsLogLevel.Information,
                Message   = "message",
                Exception = exception,
                State     = new ImmutableArrayDictionary <string, object>(
                    new Dictionary <string, object>
                {
                    [MicrosoftLogProperties.OriginalFormatKey] = "message"
                },
                    StringComparer.Ordinal)
            };

            microsoftLog.Info(exception, "message");

            microsoftLogger.Events.Single().Should().BeEquivalentTo(expectedLogEvent);
        }