public void SideEffectsOnChange() { var textBox = new System.Windows.Controls.TextBox(); Assert.IsNull(BindingOperations.GetBindingExpression(textBox, System.Windows.Controls.TextBox.TextProperty)); textBox.SetSourceValueType(typeof(int)); textBox.RaiseLoadedEvent(); Assert.NotNull(BindingOperations.GetBindingExpression(textBox, System.Windows.Controls.TextBox.TextProperty)); Assert.AreEqual(DefaultNumberStyles.DefaultInteger, textBox.GetNumberStyles()); Assert.AreEqual(DefaultStringConverters.Converters[typeof(int)], textBox.GetStringConverter()); Assert.AreEqual(DefaultRules.Rules[typeof(int)], textBox.GetValidationRules()); }
public void WithConverterExplicit() { var vm = new DummyViewModel { StringIntValue = "1" }; var textBox = new System.Windows.Controls.TextBox { DataContext = vm }; var binding = new Binding { Converter = new StringToIntConverter(), Path = new PropertyPath(DummyViewModel.StringIntValuePropertyName), Mode = BindingMode.TwoWay }; textBox.SetSourceValueType(SourceValueTypes.Int32); BindingOperations.SetBinding(textBox, Input.ValueProperty, binding); DesignMode.IsInDesignModeForTests = true; textBox.RaiseLoadedEvent(); Assert.AreEqual(typeof(int), textBox.GetSourceValueType()); }