Skip to content

Extends ApprovalTests for approval of WPF through screenshot verification.

License

Notifications You must be signed in to change notification settings

approvals/ApprovalTests.Net.Wpf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ApprovalTests.Wpf

Extends ApprovalTests for approval of WPF through screenshot verification.

The NuGet package NuGet Status

https://nuget.org/packages/ApprovalTests.Wpf/

PM> Install-Package ApprovalTests.Wpf

Usage

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));
    }
}

snippet source / anchor

BindsWithoutError

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);

snippet source / anchor

Links

About

Extends ApprovalTests for approval of WPF through screenshot verification.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages