private void CreateMappingsForLocalTimeConverter() { var converter = new LocalTimeConverter(); CreateMap <LocalTime, TimeSpan>().ConvertUsing(converter); CreateMap <LocalTime?, TimeSpan?>().ConvertUsing(converter); CreateMap <TimeSpan, LocalTime>().ConvertUsing(converter); CreateMap <TimeSpan?, LocalTime?>().ConvertUsing(converter); CreateMap <LocalTime, DateTime>().ConvertUsing(converter); CreateMap <LocalTime?, DateTime?>().ConvertUsing(converter); CreateMap <DateTime, LocalTime>().ConvertUsing(converter); CreateMap <DateTime?, LocalTime?>().ConvertUsing(converter); }
public void MustThrowFormatExceptionWhenInputIsInWrongFormat(string source) { LocalTimeConverter converter = null; try { converter = new LocalTimeConverter(); } catch { Assert.Inconclusive(); } Assert.That(() => converter.Convert(source, new LocalTime(), null), Throws.InstanceOf <FormatException>()); }
public void MustThrowArgumentOutOfRangeExceptionWhenTimeIsOutOfRange(string source) { LocalTimeConverter converter = null; try { converter = new LocalTimeConverter(); } catch { Assert.Inconclusive(); } Assert.That(() => converter.Convert(source, new LocalTime(), null), Throws.InstanceOf <ArgumentOutOfRangeException>()); }
public void ShouldParseDateTimeStringProperly(string source, int hours, int minutes, int seconds) { LocalTimeConverter converter = null; try { converter = new LocalTimeConverter(); } catch { Assert.Inconclusive(); } var localTime = converter.Convert(source, new LocalTime(), null); Assert.That(localTime.Hour, Is.EqualTo(hours)); Assert.That(localTime.Minute, Is.EqualTo(minutes)); Assert.That(localTime.Second, Is.EqualTo(seconds)); }
public void ShouldThrowExceptionWhenSourceIsNullOrWhiteSpace(string source) { var converter = new LocalTimeConverter(); Assert.That(() => converter.Convert(source, new LocalTime(), null), Throws.InstanceOf <ArgumentOutOfRangeException>()); }