Home

Awesome

<img src="/src/icon.png" height="30px"> Verify.CommunityToolkit.Mvvm

Discussions Build status NuGet Status

Extends Verify to allow verification of CommunityToolkit.Mvvm.

NuGet package

https://nuget.org/packages/Verify.CommunityToolkit.Mvvm/

Usage

<!-- snippet: Enable -->

<a id='snippet-Enable'></a>

[ModuleInitializer]
public static void Initialize() =>
    VerifyCommunityToolkitMvvm.Initialize();

<sup><a href='/src/Tests/ModuleInitializer.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-Enable' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

RelayCommand

<!-- snippet: RelayCommand -->

<a id='snippet-RelayCommand'></a>

[Fact]
public Task RelayCommand()
{
    var content = new RelayCommand(ActionMethod, CanExecuteMethod);
    return Verify(content);
}

<sup><a href='/src/Tests/Tests.cs#L10-L19' title='Snippet source file'>snippet source</a> | <a href='#snippet-RelayCommand' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Results in:

<!-- snippet: Tests.RelayCommand.verified.txt -->

<a id='snippet-Tests.RelayCommand.verified.txt'></a>

{
  Execute: Tests.ActionMethod(),
  CanExecute: Tests.CanExecuteMethod()
}

<sup><a href='/src/Tests/Tests.RelayCommand.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.RelayCommand.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

AsyncRelayCommand

<!-- snippet: AsyncRelayCommand -->

<a id='snippet-AsyncRelayCommand'></a>

[Fact]
public Task AsyncRelayCommand()
{
    var content = new AsyncRelayCommand(ActionMethodAsync, CanExecuteMethod);
    return Verify(content);
}

<sup><a href='/src/Tests/Tests.cs#L42-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-AsyncRelayCommand' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Results in:

<!-- snippet: Tests.AsyncRelayCommand.verified.txt -->

<a id='snippet-Tests.AsyncRelayCommand.verified.txt'></a>

{
  Execute: Tests.ActionMethodAsync(),
  CanExecute: Tests.CanExecuteMethod()
}

<sup><a href='/src/Tests/Tests.AsyncRelayCommand.verified.txt#L1-L4' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.AsyncRelayCommand.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->