public void From_string() { Mapper.Map <string, byte?>("12").ShouldBe((byte)12); Mapper.Map <string, sbyte>("12").ShouldBe((sbyte)12); Mapper.Map <string, float>("12").ShouldBe(12); Mapper.Map <string, double?>("12").ShouldBe(12); Mapper.Map <string, decimal?>("12").ShouldBe(12); Mapper.Map <string, ushort>("12").ShouldBe((ushort)12); Mapper.Map <string, ulong>("12").ShouldBe((ulong)12); ConfigProvider.FindMapper(new TypePair(typeof(string), typeof(DateTime))).ShouldBeOfType <ConvertMapper>(); var date = DateTime.Now; Mapper.Map <DateTime>(date.ToString("O")).ShouldBe(date); }
public void ParseMapper() { ConfigProvider.FindMapper(new TypePair(typeof(string), typeof(Guid))).ShouldBeOfType <ParseStringMapper>(); var guid = Guid.NewGuid(); Mapper.Map <Guid>(guid.ToString()).ShouldBe(guid); ConfigProvider.FindMapper(new TypePair(typeof(string), typeof(TimeSpan))).ShouldBeOfType <ParseStringMapper>(); var timeSpan = TimeSpan.FromMinutes(1); Mapper.Map <TimeSpan>(timeSpan.ToString()).ShouldBe(timeSpan); ConfigProvider.FindMapper(new TypePair(typeof(string), typeof(DateTimeOffset))).ShouldBeOfType <ParseStringMapper>(); var dateTimeOffset = DateTimeOffset.Now; Mapper.Map <DateTimeOffset>(dateTimeOffset.ToString("O")).ShouldBe(dateTimeOffset); }