-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathInitializeCartCommandHandlerTests.cs
47 lines (40 loc) · 1.21 KB
/
InitializeCartCommandHandlerTests.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
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Carts.Carts;
using Carts.Carts.InitializingCart;
using Carts.Tests.Extensions.Reservations;
using Core.Testing;
using FluentAssertions;
using Xunit;
namespace Carts.Tests.Carts.InitializingCart
{
public class InitializeCartCommandHandlerTests
{
[Fact]
public async Task ForInitCardCommand_ShouldAddNewCart()
{
// Given
var repository = new FakeRepository<Cart>();
var commandHandler = new HandleInitializeCart(
repository
);
var command = InitializeCart.Create(Guid.NewGuid(), Guid.NewGuid());
// When
await commandHandler.Handle(command, CancellationToken.None);
//Then
repository.Aggregates.Should().HaveCount(1);
var cart = repository.Aggregates.Values.Single();
cart
.IsInitializedCartWith(
command.CartId,
command.ClientId
)
.HasCartInitializedEventWith(
command.CartId,
command.ClientId
);
}
}
}