Example #1
0
        private void ShouldReturnValueForDateTime()
        {
            var expected = DateTime.Now.FlushSeconds();
            var raw      = expected.ToString(CultureInfo.InvariantCulture);

            var actual = PropertyParser.ConvertOrDefault(typeof(DateTime), raw);

            Assert.Equal(expected, actual);
        }
Example #2
0
        private void ShouldReturnNullForNullableDecimal()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(decimal?), "abc");

            Assert.Null(actual);
        }
Example #3
0
        private void ShouldReturnStringAsIs()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(string), "42");

            Assert.Equal("42", actual);
        }
Example #4
0
        private void ShouldReturnValueForNullableDecimal()
        {
            var actual = (decimal?)PropertyParser.ConvertOrDefault(typeof(decimal), "0.42");

            Assert.Equal(0.42m, actual);
        }
Example #5
0
        private void ShouldReturnDefaultForDecimal()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(decimal), "abc");

            Assert.Equal(default(decimal), actual);
        }
Example #6
0
        private void ShouldReturnNullForNullableInt()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(int?), "forty-two");

            Assert.Null(actual);
        }
Example #7
0
        private void ShouldReturnDefaultForInt()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(int), "forty-two");

            Assert.Equal(default(int), actual);
        }
Example #8
0
        private void ShouldReturnValueForNullableInt()
        {
            var actual = (int?)PropertyParser.ConvertOrDefault(typeof(int), "42");

            Assert.Equal(42, actual);
        }
Example #9
0
        private void ShouldReturnNullForNullableDateTime()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(DateTime?), "not now");

            Assert.Null(actual);
        }
Example #10
0
        private void ShouldReturnDefaultForDateTime()
        {
            var actual = PropertyParser.ConvertOrDefault(typeof(DateTime), "not now");

            Assert.Equal(default(DateTime), actual);
        }