-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMockRequestSnapshotService.cs
54 lines (41 loc) · 1.42 KB
/
MockRequestSnapshotService.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace Fifthweek.Payments.Tests.Shared
{
using System.Threading.Tasks;
using Fifthweek.Api.Identity.Shared.Membership;
using Fifthweek.Payments.SnapshotCreation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public class MockRequestSnapshotService : IRequestSnapshotService
{
private UserId userId;
private SnapshotType snapshotType;
private bool throwException;
private TrackingConnectionFactory connectionFactory;
public void ThrowException()
{
this.throwException = true;
}
public void VerifyConnectionDisposed(TrackingConnectionFactory connectionFactory)
{
this.connectionFactory = connectionFactory;
}
public void VerifyCalledWith(UserId userId, SnapshotType snapshotType)
{
Assert.AreEqual(userId, this.userId);
Assert.AreEqual(snapshotType, this.snapshotType);
}
public Task ExecuteAsync(UserId userId, SnapshotType snapshotType)
{
this.userId = userId;
this.snapshotType = snapshotType;
if (this.throwException)
{
throw new SnapshotException();
}
if (this.connectionFactory != null)
{
Assert.IsTrue(this.connectionFactory.ConnectionDisposed);
}
return Task.FromResult(0);
}
}
}