public void ValuesConvertToNullableTimeSpan() { var result = (System.TimeSpan?)KeyValuePairSettings.ConvertToType("00:01:00", typeof(System.TimeSpan?)); Assert.Equal(System.TimeSpan.FromMinutes(1), result); }
public void ValuesConvertToEnumMembers() { var result = (LogEventLevel)KeyValuePairSettings.ConvertToType("Information", typeof(LogEventLevel)); Assert.Equal(LogEventLevel.Information, result); }
public void EmptyStringValuesConvertToNullIfTargetIsNullable() { var result = (int?)KeyValuePairSettings.ConvertToType("", typeof(int?)); Assert.True(result == null); }
public void ConvertibleValuesConvertToTIfTargetIsNullable() { var result = (int?)KeyValuePairSettings.ConvertToType("3", typeof(int?)); Assert.True(result == 3); }
public void StringValuesConvertToDefaultInstancesIfTargetIsInterface() { var result = (object)KeyValuePairSettings.ConvertToType("Serilog.Formatting.Json.JsonFormatter", typeof(ITextFormatter)); Assert.IsType <JsonFormatter>(result); }
public void NullValuesConvertToNullIfTargetIsNullable() { var result = (int?)KeyValuePairSettings.ConvertToType(null, typeof(int?)); Assert.That(result == null); }
public void LoggingLevelSwitchNameValidityScenarios(string switchName, bool expectedValid) { Assert.True(KeyValuePairSettings.IsValidSwitchName(switchName) == expectedValid, $"expected IsValidSwitchName({switchName}) to return {expectedValid} "); }