public void ReferencingUndeclaredLevelSwitchThrows() { var resolutionContext = new ResolutionContext(); resolutionContext.AddLevelSwitch("$anotherSwitch", new LoggingLevelSwitch(LogEventLevel.Verbose)); var stringArgumentValue = new StringArgumentValue("$mySwitch"); var ex = Assert.Throws <InvalidOperationException>(() => stringArgumentValue.ConvertTo(typeof(LoggingLevelSwitch), resolutionContext) ); Assert.Contains("$mySwitch", ex.Message); Assert.Contains("\"LevelSwitches\":{\"$mySwitch\":", ex.Message); }
public void LevelSwitchesCanBeLookedUpByName() { var @switch = new LoggingLevelSwitch(LogEventLevel.Verbose); var switchName = "$theSwitch"; var resolutionContext = new ResolutionContext(); resolutionContext.AddLevelSwitch(switchName, @switch); var stringArgumentValue = new StringArgumentValue(switchName); var resolvedSwitch = stringArgumentValue.ConvertTo(typeof(LoggingLevelSwitch), resolutionContext); Assert.IsType <LoggingLevelSwitch>(resolvedSwitch); Assert.Same(@switch, resolvedSwitch); }