-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentTests_When_State_Is_Draft.cs
54 lines (48 loc) · 1.64 KB
/
DocumentTests_When_State_Is_Draft.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 FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Library.Tests.Unit
{
public class DocumentTests_When_State_Is_Draft
{
private Document sut;
public DocumentTests_When_State_Is_Draft()
{
sut = new Document();
sut.State.Should().BeOfType<DraftState>();
}
public static IEnumerable<object[]> ValidTransitions()
{
return new List<object[]>
{
new object[] { new Action<Document>(a=> a.Moderate()), typeof(ModerationState) },
new object[] { new Action<Document>(a=> a.Archive()), typeof(ArchivedState) },
};
}
[Theory]
[MemberData(nameof(ValidTransitions))]
public void Should_change_state_on_valid_transitions(Action<Document> transitionAction, Type expectedState)
{
transitionAction.Invoke(sut);
sut.State.Should().BeOfType(expectedState);
}
public static IEnumerable<object[]> InvalidTransitions()
{
return new List<object[]>
{
new object[] { new Action<Document>(a=> a.Publish())},
};
}
[Theory]
[MemberData(nameof(InvalidTransitions))]
public void Should_throw_exception_on_invalid_transitions(Action<Document> transitionAction)
{
var action = new Action(() => transitionAction.Invoke(sut));
action.Should().Throw<NotSupportedException>();
sut.State.Should().BeOfType<DraftState>();
}
}
}