Exemplo n.º 1
0
        public void ValuesConvertToNullableTimeSpan()
        {
            var result = (System.TimeSpan?)KeyValuePairSettings.ConvertToType("00:01:00", typeof(System.TimeSpan?));

            Assert.Equal(System.TimeSpan.FromMinutes(1), result);
        }
Exemplo n.º 2
0
        public void ValuesConvertToEnumMembers()
        {
            var result = (LogEventLevel)KeyValuePairSettings.ConvertToType("Information", typeof(LogEventLevel));

            Assert.Equal(LogEventLevel.Information, result);
        }
Exemplo n.º 3
0
        public void EmptyStringValuesConvertToNullIfTargetIsNullable()
        {
            var result = (int?)KeyValuePairSettings.ConvertToType("", typeof(int?));

            Assert.True(result == null);
        }
Exemplo n.º 4
0
        public void ConvertibleValuesConvertToTIfTargetIsNullable()
        {
            var result = (int?)KeyValuePairSettings.ConvertToType("3", typeof(int?));

            Assert.True(result == 3);
        }
Exemplo n.º 5
0
        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} ");
 }