-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improved TrackUserLoginCommandHandler test
- Loading branch information
1 parent
ff19007
commit 914266a
Showing
2 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
...gy.CQRS.UnitTests/TestApplication/Commands/TrackUserLogin/TrackUserLoginCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Wemogy.CQRS.Commands.Abstractions; | ||
|
||
namespace Wemogy.CQRS.UnitTests.TestApplication.Commands.TrackUserLogin; | ||
|
||
public class TrackUserLoginCommandHandler : ICommandHandler<TrackUserLoginCommand> | ||
{ | ||
public static int CallCount { get; private set; } | ||
|
||
public static void ResetCallCount() | ||
{ | ||
CallCount = 0; | ||
} | ||
public static Dictionary<string, int> ExecutedCount { get; } = new (); | ||
|
||
public Task HandleAsync(TrackUserLoginCommand command) | ||
{ | ||
CallCount++; | ||
if (ExecutedCount.TryGetValue(command.UserId, out var count)) | ||
{ | ||
ExecutedCount[command.UserId] = count + 1; | ||
} | ||
else | ||
{ | ||
ExecutedCount[command.UserId] = 1; | ||
} | ||
|
||
return Task.CompletedTask; | ||
} | ||
} |