public void Convert() { var c = new NullableConverter(); Assert.IsNull(c.ConvertBack("", typeof(int?), null, CultureInfo.CurrentCulture)); Assert.AreEqual(1, c.ConvertBack("1", typeof(int?), null, CultureInfo.CurrentCulture)); Assert.AreEqual("", c.Convert(null, typeof(string), null, CultureInfo.CurrentCulture)); Assert.AreEqual("1", c.Convert(1, typeof(string), null, CultureInfo.CurrentCulture)); }
public void ShouldCallConverterChooserWithExtractedStructForNotNullRawValue() { var converterChooserMock = new Mock <ISettingsConverterChooser>(); var converter = new NullableConverter(converterChooserMock.Object); var rawValue = new double?(5); converter.Convert <double?, int?>(rawValue); converterChooserMock.Verify(x => x.ChooseAndConvert <double, int>(5)); }
public void ShouldCallConverterChooserWithNullForNullRawValue() { var converterChooserMock = new Mock <ISettingsConverterChooser>(); var converter = new NullableConverter(converterChooserMock.Object); var rawValue = default(int?); converter.Convert <int?, double?>(rawValue); converterChooserMock.Verify(x => x.ChooseAndConvert <int?, double>(null)); }