public void Convert_Null_NullableDateTimeDefault() { // arrange DateTimeValueConverter converter = new DateTimeValueConverter(); DateTimeType type = new DateTimeType(); DateTime?expectedUtcOutput = default(DateTime?); // act bool result = converter.TryConvert( typeof(DateTimeOffset), typeof(DateTime?), null, out object convertedValue); // assert Assert.True(result); Assert.Equal(expectedUtcOutput, convertedValue); }
public void Convert_DateTimeOffset_LocalNullableDateTime() { // arrange DateTimeValueConverter converter = new DateTimeValueConverter(); DateTimeType type = new DateTimeType(); DateTimeOffset input = new DateTimeOffset( new DateTime(2018, 04, 05, 13, 15, 0), new TimeSpan(4, 0, 0)); DateTime?expectedUtcOutput = new DateTime( 2018, 04, 05, 09, 15, 0, DateTimeKind.Utc); // act bool result = converter.TryConvert( typeof(DateTimeOffset), typeof(DateTime?), input, out object convertedValue); // assert Assert.True(result); Assert.IsType <DateTime>(convertedValue); Assert.Equal(expectedUtcOutput, ((DateTime)convertedValue).ToUniversalTime()); }