public void CanConvertFromTest()
 {
     var converter = new GridLengthConverter();
     Assert.IsTrue(converter.CanConvertFrom(typeof(string)));
     Assert.IsTrue(converter.CanConvertFrom(typeof(int)));
     Assert.IsTrue(converter.CanConvertFrom(typeof(double)));
     Assert.IsFalse(converter.CanConvertFrom(typeof(object)));
     Assert.IsFalse(converter.CanConvertFrom(typeof(GridLength)));
 }
Exemplo n.º 2
0
 public void CanConvertFromTest()
 {
     var converter = new GridLengthConverter();
     Assert.IsTrue(converter.CanConvertFrom(typeof(string)));
     Assert.IsTrue(converter.CanConvertFrom(typeof(int)));
     Assert.IsTrue(converter.CanConvertFrom(typeof(double)));
     Assert.IsFalse(converter.CanConvertFrom(typeof(object)));
     Assert.IsFalse(converter.CanConvertFrom(typeof(GridLength)));
 }
        public void CanConvertFrom()
        {
            _converter.CanConvertFrom(null, typeof(int)).Should().BeTrue();
            _converter.CanConvertFrom(null, typeof(string)).Should().BeTrue();

            _converter.CanConvertFrom(null, typeof(void)).Should().BeFalse();
            _converter.CanConvertFrom(null, typeof(object)).Should().BeFalse();
            _converter.CanConvertFrom(null, typeof(ConsoleColorConverter)).Should().BeFalse();
        }
        public GridLength GetGridLength <T>(T input)
        {
            var result = new GridLength(1, GridUnitType.Star);

            if (!_gridLengthConverter.CanConvertFrom(input.GetType()))
            {
                return(result);
            }
            var convertedValue = _gridLengthConverter.ConvertFrom(input);

            if (convertedValue != null)
            {
                result = (GridLength)convertedValue;
            }
            return(result);
        }