-
Notifications
You must be signed in to change notification settings - Fork 31
/
EventHandler.cs
54 lines (45 loc) · 1.55 KB
/
EventHandler.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
using Aggregates;
using System;
using System.Threading.Tasks;
using Xunit;
using FluentAssertions;
namespace Test
{
public class EventHandler : TestSubject<Example.Todo.Application.Handler>
{
[Fact]
public async Task CreateTodo()
{
var @event = Context.Create<Example.Todo.Events.Added>(x =>
{
x.TodoId = Context.Id();
x.Message = "test";
});
await Sut.Handle(@event, Context).ConfigureAwait(false);
Context.App.Check<Example.Todo.Models.TodoResponse>(Context.Id()).Added();
}
[Fact]
public async Task EditTodo()
{
Context.App.Plan<Example.Todo.Models.TodoResponse>(Context.Id()).Exists();
var @event = Context.Create<Example.Todo.Events.Edited>(x =>
{
x.TodoId = Context.Id();
x.Message = "test2";
});
await Sut.Handle(@event, Context).ConfigureAwait(false);
Context.App.Check<Example.Todo.Models.TodoResponse>(Context.Id()).Updated();
}
[Fact]
public async Task RemoveTodo()
{
Context.App.Plan<Example.Todo.Models.TodoResponse>(Context.Id()).Exists();
var @event = Context.Create<Example.Todo.Events.Removed>(x =>
{
x.TodoId = Context.Id();
});
await Sut.Handle(@event, Context).ConfigureAwait(false);
Context.App.Check<Example.Todo.Models.TodoResponse>(Context.Id()).Deleted();
}
}
}