Awesome
<img src="/src/icon.png" height="30px"> Verify.WinForms
Extends Verify to allow verification of WinForms UIs.
See Milestones for release notes.
NuGet package
https://nuget.org/packages/Verify.WinForms/
Usage
<!-- snippet: enable --><a id='snippet-enable'></a>
[ModuleInitializer]
public static void Init() =>
VerifyWinForms.Initialize();
<sup><a href='/src/Tests/ModuleInit.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-enable' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Form
A visual element (Form/Control etc) can be verified as follows:
<!-- snippet: FormUsage --><a id='snippet-FormUsage'></a>
[Test]
public Task FormUsage() =>
Verify(new MyForm());
<sup><a href='/src/Tests/TheTests.cs#L6-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-FormUsage' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->With the state of the element being rendered as a verified file:
TheTests.FormUsage.Net.verified.png:
<img src="/src/Tests/TheTests.FormUsage.Net.verified.png" width="200px">ContextMenuStrip
A ContextMenuStrip
can be verified as follows:
<a id='snippet-ContextMenuStrip'></a>
[Test]
public Task ContextMenuStrip()
{
var menu = new ContextMenuStrip();
var items = menu.Items;
items.Add(new ToolStripMenuItem("About"));
items.Add(new ToolStripMenuItem("Exit"));
return Verify(menu);
}
<sup><a href='/src/Tests/TheTests.cs#L22-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-ContextMenuStrip' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->With the state of the element being rendered as a verified file:
TheTests.FormUsage.Net.verified.png:
<img src="/src/Tests/TheTests.ContextMenuStrip.Net.verified.png" width="200px">OS specific rendering
The rendering of Form elements can very slightly between different OS versions. This can make verification on different machines (eg CI) problematic. There are several approaches to mitigate this:
- Using a custom comparer
Icon
Gem designed by Adnen Kadri from The Noun Project.