-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathScenarioTesterExtensions.cs
32 lines (30 loc) · 1.09 KB
/
ScenarioTesterExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Moq;
using SparkyTestHelpers.Scenarios;
namespace SparkyTestHelpers.Moq
{
/// <summary>
/// <see cref="ScenarioTester{TScenario}"/> extension methods.
/// </summary>
public static class ScenarioTesterExtensions
{
/// <summary>
/// Call "ResetCalls" for each specified <see cref="Mock"/> before testing each scenario.
/// </summary>
/// <typeparam name="TScenario">The scenario type.</typeparam>
/// <param name="tester">The <see cref="ScenarioTester{TScenario}"/>.</param>
/// <param name="mocksToReset">The <see cref="Mock"/>(s) to reset.</param>
/// <returns>The <see cref="ScenarioTester{TScenario}"/>.</returns>
public static ScenarioTester<TScenario> WithMoqResetsFor<TScenario>(
this ScenarioTester<TScenario> tester, params Mock[] mocksToReset)
{
tester.BeforeEachTest(scenario =>
{
foreach (Mock mock in mocksToReset)
{
mock.ResetCalls();
}
});
return tester;
}
}
}