示例#1
0
        public void ObjectToVisibilityConverterTest()
        {
            ObjectToVisibilityConverter objectToVisibilityConverter = new ObjectToVisibilityConverter();

            objectToVisibilityConverter.ProvideValue(null).Should().Be(objectToVisibilityConverter);

            objectToVisibilityConverter.Convert(null, typeof(Visibility), null, null).Should().Be(Visibility.Collapsed);
            objectToVisibilityConverter.Convert("something", typeof(Visibility), null, null).Should().Be(Visibility.Visible);
            objectToVisibilityConverter.Convert(null, typeof(Visibility), "Reverse", null).Should().Be(Visibility.Visible);
            objectToVisibilityConverter.Convert("something", typeof(Visibility), "Reverse", null).Should().Be(Visibility.Collapsed);

            objectToVisibilityConverter.ConvertBack(null, typeof(object), null, null).Should().BeNull();
        }
        private static void AssertConverts(object value, Visibility exptectedResult)
        {
            var converter = new ObjectToVisibilityConverter();
            var result    = converter.Convert(value, null, null, null);

            Assert.AreEqual(exptectedResult, result);
        }
 public void ConvertNullObjectTest()
 {
     var converter = new ObjectToVisibilityConverter();
     var result = converter.Convert(null, typeof(object), null, null);
     Assert.AreEqual(Visibility.Collapsed, result);
 }
示例#4
0
        public void ConvertingNullReturnsHidden()
        {
            var visibility = _visibilityConverter.Convert(null, null, null, null);

            visibility.Should().Be(Visibility.Hidden);
        }