Esempio n. 1
0
        public void TestBindingWithConverter()
        {
            var converter = new FunctionalConverter <bool, bool>((value, _) => value, (value, _) => value);
            var binding   = new Binding("Some property")
            {
                Converter = converter
            };

            Binding("Some property", converter).Should().BeEquivalentTo(binding);
        }
Esempio n. 2
0
        public void TestFunctionalConverter()
        {
            var converter = new FunctionalConverter <bool, Visibility>(
                convert: (value, culture) => value ? Visibility.Visible : Visibility.Hidden,
                convertBack: (value, culture) => value == Visibility.Visible);

            converter.Convert(null, null, null, CultureInfo.CurrentCulture).Should().Be(Visibility.Hidden);
            converter.Convert(true, null, null, CultureInfo.CurrentCulture).Should().Be(Visibility.Visible);

            converter.ConvertBack(null, null, null, CultureInfo.CurrentCulture).Should().Be(true);
            converter.ConvertBack(Visibility.Hidden, null, null, CultureInfo.CurrentCulture).Should().Be(false);
        }