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); }
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)); }
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); }
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); }
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); }
public void TestSetMaxLengthWithNullBinding() { editor.DataContext = Substitute.For <object>(); AttributePropertySetter.SetAttributeProperty(editor); Assert.Equal(0, editor.MaxLength); }