public void TestFailedBindings() { var viewModel = new TestViewModel(); Binding myBinding = new Binding(TestViewModel.MyPropertyPropertyName + "BOGUS"); myBinding.Source = viewModel; var e = ExceptionUtilities.GetException(() => WpfBindingsAssert.BindsWithoutError(viewModel, () => { var textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, myBinding); return(textBox); })); Approvals.Verify(e.Message, s => Regex.Replace(s, @"\(HashCode=\d+\)", "(Hashcode)")); }
void TestFailedBindings() { #region BindsWithoutError var viewModel = new ViewModel(); var myBinding = new Binding(nameof(ViewModel.MyProperty)) { Source = viewModel }; var exception = ExceptionUtilities.GetException( () => WpfBindingsAssert.BindsWithoutError(viewModel, () => { var textBox = new TextBox(); textBox.SetBinding(TextBox.TextProperty, myBinding); return(textBox); })); Assert.Null(exception); #endregion }