public void Should_Throw_When_Trying_To_Convert_Invalid_Types_Without_Specified_Custom_Converter() { var sut = BuildAndConfigureFor <ConversionDto <int, string> >(new Dictionary <Type, Expression>()); using (var reader = ConversionDto <int, string> .BuildReader("12345")) { reader.Read(); var actual = sut.Map <ConversionDto <int, string> >(reader); Assert.Fail( "A conversion for this type should not be supported without explicit TypeConvertor Expression injection to the mapper."); } }
public void Should_Correctly_Map_IntegerAsString() { var sut = BuildAndConfigureFor <ConversionDto <int, string> >(); int expectedValue = 12345; string expectedStringValue = expectedValue.ToString(); using (var reader = ConversionDto <int, string> .BuildReader(expectedStringValue)) { reader.Read(); var actual = sut.Map <ConversionDto <int, string> >(reader); Assert.AreEqual(expectedValue, actual.PropertyToTest); } }
public void Should_Correctly_Map_StringAsDateTime() { var sut = BuildAndConfigureFor <ConversionDto <DateTime, string> >(); var expectedDateValue = new DateTime(9999, 12, 31); string expectedStringValue = expectedDateValue.ToShortDateString(); using (var reader = ConversionDto <DateTime, string> .BuildReader(expectedStringValue)) { reader.Read(); var actual = sut.Map <ConversionDto <DateTime, string> >(reader); Assert.AreEqual(expectedDateValue, actual.PropertyToTest); } }
public void Should_Correctly_Map_List_Of_Strings() { var sut = BuildAndConfigureFor <ConversionDto <List <string>, string> >(); const string concatenatedValues = "this,will,be,split,to,multiple,strings"; int expectedListCount = concatenatedValues.Split(',').Length; using (var reader = ConversionDto <List <string>, string> .BuildReader(concatenatedValues)) { reader.Read(); var actual = sut.Map <ConversionDto <List <string>, string> >(reader); Assert.AreEqual(expectedListCount, actual.PropertyToTest.Count); Assert.AreEqual("this", actual.PropertyToTest.First()); Assert.AreEqual("split", actual.PropertyToTest[3]); Assert.AreEqual("strings", actual.PropertyToTest.Last()); } }