コード例 #1
0
        public void TestSetMaxLengthBindingDoesNotHaveResolvedSourceAndContextItemIsNull()
        {
            editor.DataContext = Substitute.For <object>();
            Binding myBinding = new Binding("StringLengthProperty");

            editor.SetBinding(TextBox.TextProperty, myBinding);
            AttributePropertySetter.SetAttributeProperty(editor);
            Assert.Equal(0, editor.MaxLength);
        }
コード例 #2
0
        public void TestSetMaxLengthWithInvalidControlType()
        {
            var invalidEditor = new RichTextBox();
            StringLengthTestClass testObject = new StringLengthTestClass();
            Binding myBinding = new Binding("StringLengthProperty")
            {
                Source = testObject
            };

            invalidEditor.SetBinding(TextBox.TextProperty, myBinding);
            Assert.Throws <ArgumentException>(() => AttributePropertySetter.SetAttributeProperty(invalidEditor));
        }
コード例 #3
0
        public void TestSetMaxLengthWithNullDataContext()
        {
            StringLengthTestClass testObject = new StringLengthTestClass();
            Binding myBinding = new Binding("StringLengthProperty")
            {
                Source = testObject
            };

            editor.SetBinding(TextBox.TextProperty, myBinding);
            AttributePropertySetter.SetAttributeProperty(editor);
            Assert.Equal(0, editor.MaxLength);
        }
コード例 #4
0
        public void TestSetMaxLengthBindingWhenAttributeIsInherited()
        {
            editor.DataContext = Substitute.For <object>();
            StringLengthTestClass myMockObject = new ChildStringLengthTestClass();
            Binding myBinding = new Binding("StringLengthProperty")
            {
                Source = myMockObject
            };

            editor.SetBinding(TextBox.TextProperty, myBinding);
            AttributePropertySetter.SetAttributeProperty(editor);
            Assert.Equal(50, editor.MaxLength);
        }
コード例 #5
0
        public void TestSetMaxLengthBindingHasResolvedSourceWithTextBinding()
        {
            editor.DataContext = Substitute.For <object>();
            StringLengthTestClass testObject = new StringLengthTestClass();
            Binding myBinding = new Binding("StringLengthProperty")
            {
                Source = testObject
            };

            editor.SetBinding(TextBox.TextProperty, myBinding);
            AttributePropertySetter.SetAttributeProperty(editor);
            Assert.Equal(50, editor.MaxLength);
        }
コード例 #6
0
 public void TestSetMaxLengthWithNullBinding()
 {
     editor.DataContext = Substitute.For <object>();
     AttributePropertySetter.SetAttributeProperty(editor);
     Assert.Equal(0, editor.MaxLength);
 }