public void ConvertToTest() { var converter = new GridLengthConverter(); Assert.AreEqual("Auto", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Auto), typeof(string))); Assert.AreEqual("*", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Star), typeof(string))); Assert.AreEqual("1.5*", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.5, GridUnitType.Star), typeof(string))); Assert.AreEqual("100", converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(100, GridUnitType.Pixel), typeof(string))); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (targetType == typeof(string)) { return(_converter.ConvertTo(value, targetType)); } else { return(_converter.ConvertTo(value, typeof(string))); } }
public void ConvertToShouldThrowWhenTypeIsWrong() { var converter = new GridLengthConverter(); AssertHelper.Throws<ArgumentException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Auto), typeof(double))); }
public void ConvertToShouldThrowWhenValueIsWrongType() { var converter = new GridLengthConverter(); AssertHelper.Throws<ArgumentException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, new object(), typeof(string))); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return(_converter.ConvertTo(value, targetType)); }
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return(m_Converter.ConvertTo(value, targetType)); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return(value != null?_converter.ConvertTo(value, targetType) : Binding.DoNothing); }
public void ConvertToInvalidDestination() { new Action(() => _converter.ConvertTo(GridLength.Auto, typeof(Guid))).Should().Throw <NotSupportedException>(); }