コード例 #1
0
        public void Initiate_Should_Not_Enable_Data_Validation_With_BindingPriority_TemplatedParent()
        {
            var textBlock = new TextBlock
            {
                DataContext = new Class1(),
            };

            var target = new Binding(nameof(Class1.Foo)) { Priority = BindingPriority.TemplatedParent };
            var instanced = target.Initiate(textBlock, TextBlock.TextProperty, enableDataValidation: true);
            var subject = (BindingExpression)instanced.Subject;
            object result = null;

            subject.Subscribe(x => result = x);

            Assert.IsType<string>(result);
        }
コード例 #2
0
        public void Initiate_Should_Enable_Data_Validation_With_BindingPriority_LocalValue()
        {
            var textBlock = new TextBlock
            {
                DataContext = new Class1(),
            };

            var target = new Binding(nameof(Class1.Foo));
            var instanced = target.Initiate(textBlock, TextBlock.TextProperty, enableDataValidation: true);
            var subject = (BindingExpression)instanced.Subject;
            object result = null;

            subject.Subscribe(x => result = x);

            Assert.Equal(new BindingNotification("foo"), result);
        }
コード例 #3
0
ファイル: BindingTests.cs プロジェクト: CarlSosaDev/Avalonia
        public void Should_Use_DefaultValueConverter_When_No_Converter_Specified()
        {
            var target = new TextBlock(); ;
            var binding = new Binding
            {
                Path = "Foo",
            };

            var result = binding.Initiate(target, TextBox.TextProperty).Subject;

            Assert.IsType<DefaultValueConverter>(((ExpressionSubject)result).Converter);
        }
コード例 #4
0
ファイル: BindingTests.cs プロジェクト: CarlSosaDev/Avalonia
        public void Should_Use_Supplied_Converter()
        {
            var target = new TextBlock();
            var converter = new Mock<IValueConverter>();
            var binding = new Binding
            {
                Converter = converter.Object,
                Path = "Foo",
            };

            var result = binding.Initiate(target, TextBox.TextProperty).Subject;

            Assert.Same(converter.Object, ((ExpressionSubject)result).Converter);
        }
コード例 #5
0
ファイル: BindingTests.cs プロジェクト: jkoritzinsky/Avalonia
        public void Should_Pass_ConverterParameter_To_Supplied_Converter()
        {
            var target = new TextBlock();
            var converter = new Mock<IValueConverter>();
            var binding = new Binding
            {
                Converter = converter.Object,
                ConverterParameter = "foo",
                Path = "Bar",
            };

            var result = binding.Initiate(target, TextBox.TextProperty).Subject;

            Assert.Same("foo", ((BindingExpression)result).ConverterParameter);
        }