public void LevelOverrideMap_GetEffectiveLevel()
 {
     for (var i = 0; i < _contexts.Length; ++i)
     {
         _levelOverrideMap.GetEffectiveLevel(_contexts[i], out _, out _);
     }
 }
Ejemplo n.º 2
0
        public void OverrideScenarios(string context, bool overrideExpected, LogEventLevel expected)
        {
            var overrides = new Dictionary <string, LoggingLevelSwitch>
            {
                ["MyApp"] = new LoggingLevelSwitch(LogEventLevel.Debug),
                ["MyApp.Api.Controllers"] = new LoggingLevelSwitch(LogEventLevel.Information),
                ["MyApp.Api.Controllers.HomeController"] = new LoggingLevelSwitch(LogEventLevel.Warning),
                ["MyApp.Api"] = new LoggingLevelSwitch(LogEventLevel.Error)
            };

            var lom = new LevelOverrideMap(overrides, LogEventLevel.Fatal, null);

            LoggingLevelSwitch overriddenSwitch;
            LogEventLevel      overriddenLevel;

            lom.GetEffectiveLevel(context, out overriddenLevel, out overriddenSwitch);

            if (overrideExpected)
            {
                Assert.NotNull(overriddenSwitch);
                Assert.Equal(expected, overriddenSwitch.MinimumLevel);
                Assert.Equal(LevelAlias.Minimum, overriddenLevel);
            }
            else
            {
                Assert.Equal(LogEventLevel.Fatal, overriddenLevel);
                Assert.Null(overriddenSwitch);
            }
        }