public void WithConverter_NullConverter_ThrowsArgumentNullException() { OneToOneMap <string> propertyMap = Map(t => t.Value); ConvertUsingSimpleMapperDelegate <string> converter = null; Assert.Throws <ArgumentNullException>("converter", () => propertyMap.WithConverter(converter)); }
public void WithConverter_InvalidConverter_ReturnsExpected() { ConvertUsingSimpleMapperDelegate <string> converter = stringValue => { Assert.Equal("stringValue", stringValue); throw new NotSupportedException(); }; OneToOneMap <string> propertyMap = Map(t => t.Value); Assert.Same(propertyMap, propertyMap.WithConverter(converter)); ConvertUsingMapper item = propertyMap.Pipeline.CellValueMappers.OfType <ConvertUsingMapper>().Single(); object value = 1; PropertyMapperResultType result = item.Converter(new ReadCellValueResult(-1, "stringValue"), ref value); Assert.Equal(PropertyMapperResultType.Invalid, result); Assert.Equal(1, value); }
public void WithConverter_SuccessConverter_ReturnsExpected() { ConvertUsingSimpleMapperDelegate <string> converter = stringValue => { Assert.Equal("stringValue", stringValue); return("abc"); }; OneToOneMap <string> propertyMap = Map(t => t.Value); Assert.Same(propertyMap, propertyMap.WithConverter(converter)); ConvertUsingMapper item = propertyMap.Pipeline.CellValueMappers.OfType <ConvertUsingMapper>().Single(); object value = null; PropertyMapperResultType result = item.Converter(new ReadCellValueResult(-1, "stringValue"), ref value); Assert.Equal(PropertyMapperResultType.Success, result); Assert.Equal("abc", value); }