public void CanConvert_CtorWithoutCanConvert_True()
        {
            var subject = new OneWayDelegateValueConverter<int, int>((i, c) => i);

            var result = subject.CanConvert(42, CultureInfo.InvariantCulture);

            Assert.IsTrue(result);
        }
        public void CanConvert_CtorWithoutCanConvert_True()
        {
            var subject = new OneWayDelegateValueConverter <int, int>((i, c) => i);

            var result = subject.CanConvert(42, CultureInfo.InvariantCulture);

            Assert.IsTrue(result);
        }
Example #3
0
        protected virtual void Start()
        {
            var colorConverter = new OneWayDelegateValueConverter <bool, Color>(
                (available, culture) => available
                    ? EnabledColor
                    : DisabledColor);

            BindingTarget.PositionProperty.Bind(BindingType.OneWay, _viewModel.PositionProperty);
            UpButton.CommandProperty.Bind(BindingType.OneWay, _viewModel.UpButtonCommandProperty);
            UpButton.TextProperty.Bind(BindingType.OneWay, _viewModel.UpButtonTextProperty);
            UpButton.TextColorProperty.Bind(_viewModel.UpAvailableProperty, colorConverter);
            DownButton.CommandProperty.Bind(BindingType.OneWay, _viewModel.DownButtonCommandProperty);
            DownButton.TextProperty.Bind(BindingType.OneWay, _viewModel.DownButtonTextProperty);
            DownButton.TextColorProperty.Bind(_viewModel.DownAvailableProperty, colorConverter);
        }
Example #4
0
        protected virtual void Start()
        {
            var colorConverter = new OneWayDelegateValueConverter<bool, Color>(
                (available, culture) => available
                    ? EnabledColor
                    : DisabledColor);

            BindingTarget.PositionProperty.Bind(BindingType.OneWay, _viewModel.PositionProperty);
            UpButton.CommandProperty.Bind(BindingType.OneWay, _viewModel.UpButtonCommandProperty);
            UpButton.TextProperty.Bind(BindingType.OneWay, _viewModel.UpButtonTextProperty);
            UpButton.TextColorProperty.Bind(_viewModel.UpAvailableProperty, colorConverter);
            DownButton.CommandProperty.Bind(BindingType.OneWay, _viewModel.DownButtonCommandProperty);
            DownButton.TextProperty.Bind(BindingType.OneWay, _viewModel.DownButtonTextProperty);
            DownButton.TextColorProperty.Bind(_viewModel.DownAvailableProperty, colorConverter);
        }
        public void Convert_DelegateCalled()
        {
            const int input = 42;
            const int output = 24;
            var culture = CultureInfo.InvariantCulture;

            var called = false;
            var subject = new OneWayDelegateValueConverter<int, int>(
                (i, c) =>
                {
                    called = true;
                    Assert.AreEqual(input, i);
                    Assert.AreEqual(culture, c);
                    return output;
                });

            var result = subject.Convert(input, culture);

            Assert.AreEqual(output, result);
            Assert.IsTrue(called);
        }
        public void Convert_DelegateCalled()
        {
            const int input   = 42;
            const int output  = 24;
            var       culture = CultureInfo.InvariantCulture;

            var called  = false;
            var subject = new OneWayDelegateValueConverter <int, int>(
                (i, c) =>
            {
                called = true;
                Assert.AreEqual(input, i);
                Assert.AreEqual(culture, c);
                return(output);
            });

            var result = subject.Convert(input, culture);

            Assert.AreEqual(output, result);
            Assert.IsTrue(called);
        }