Awesome
<!-- GENERATED FILE - DO NOT EDIT This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets). Source File: /readme.source.md To change this file edit the source file and then run MarkdownSnippets. --><img src="https://avatars3.githubusercontent.com/u/36907" height="30px"> ApprovalTests.Wpf
Extends ApprovalTests for approval of WPF through screenshot verification.
The NuGet package
https://nuget.org/packages/ApprovalTests.Wpf/
PM> Install-Package ApprovalTests.Wpf
Usage
Given the following binding model:
<!-- snippet: model --><a id='snippet-model'/></a>
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));
}
}
<sup>snippet source / anchor</sup>
<!-- endsnippet -->BindsWithoutError
The bindings can be verified using the following:
<!-- snippet: BindsWithoutError --><a id='snippet-bindswithouterror'/></a>
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);
<sup>snippet source / anchor</sup>
<!-- endsnippet -->Links
- NuGet: https://nuget.org/packages/ApprovalTests.Wpf/
- Build: