Exemplo n.º 1
0
        public void Log_StartsWithLogPrefix()
        {
            var interceptor = new TestUnityLoggerInterceptor();
            var logger      = new UnityLogger(new SentryOptions {
                DiagnosticLevel = SentryLevel.Debug
            }, interceptor);

            logger.Log(SentryLevel.Debug, "TestLog");

            StringAssert.StartsWith(UnityLogger.LogPrefix, interceptor.LogMessage);
        }
Exemplo n.º 2
0
        public void Log_LowerLevelThanInitializationLevel_DisablesLogger(SentryLevel initializationLevel, SentryLevel lowerLevel)
        {
            var interceptor = new TestUnityLoggerInterceptor();
            var logger      = new UnityLogger(new SentryOptions {
                DiagnosticLevel = initializationLevel
            }, interceptor);

            const string expectedLog = "Some log";

            logger.Log(lowerLevel, expectedLog);

            Assert.False(logger.IsEnabled(lowerLevel));
            Assert.False(interceptor.LogMessage.Contains(expectedLog));
        }
Exemplo n.º 3
0
        public void Log_DebugLevels_Correspond([Values] SentryLevel sentryLevel)
        {
            LogAssert.ignoreFailingMessages = true;

            var interceptor = new TestUnityLoggerInterceptor();
            var logger      = new UnityLogger(new SentryOptions {
                DiagnosticLevel = sentryLevel
            }, interceptor);

            const string expectedLog = "Some log";

            logger.Log(sentryLevel, expectedLog);

            Assert.True(logger.IsEnabled(sentryLevel));
            Assert.True(interceptor.LogMessage.Contains("Sentry"));
            Assert.True(interceptor.LogMessage.Contains(expectedLog));
            Assert.True(interceptor.LogMessage.Contains(sentryLevel.ToString()));
        }