예제 #1
0
 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 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)));
 }
예제 #3
0
 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)));
 }
예제 #6
0
 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     return(_converter.ConvertTo(value, targetType));
 }
예제 #7
0
 public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(m_Converter.ConvertTo(value, targetType));
 }
예제 #8
0
 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(value != null?_converter.ConvertTo(value, targetType) : Binding.DoNothing);
 }
예제 #9
0
 public void ConvertToShouldThrowWhenTypeIsWrong()
 {
     var converter = new GridLengthConverter();
     AssertHelper.Throws<ArgumentException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, new GridLength(1.0, GridUnitType.Auto), typeof(double)));
 }
예제 #10
0
 public void ConvertToShouldThrowWhenValueIsWrongType()
 {
     var converter = new GridLengthConverter();
     AssertHelper.Throws<ArgumentException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, new object(), typeof(string)));
 }
 public void ConvertToInvalidDestination()
 {
     new Action(() => _converter.ConvertTo(GridLength.Auto, typeof(Guid))).Should().Throw <NotSupportedException>();
 }