Extends ApprovalTests for approval of WPF through screenshot verification.
https://nuget.org/packages/ApprovalTests.Wpf/
PM> Install-Package ApprovalTests.Wpf
Given the following binding model:
public class ViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate { };
string myProperty;
public string MyProperty
{
get => myProperty;
set
{
myProperty = value;
RaisePropertyChanged();
}
}
void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
The bindings can be verified using the following:
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);
- NuGet: https://nuget.org/packages/ApprovalTests.Wpf/
- Build: