-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathIAggregateTests.cs
More file actions
100 lines (87 loc) · 2.55 KB
/
Copy pathIAggregateTests.cs
File metadata and controls
100 lines (87 loc) · 2.55 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
namespace NEventStore.Domain.Tests
{
using System;
using NEventStore.Persistence.AcceptanceTests.BDD;
using FluentAssertions;
#if MSTEST
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endif
#if NUNIT
using NUnit.Framework;
#endif
#if XUNIT
using Xunit;
using Xunit.Should;
#endif
#if MSTEST
[TestClass]
#endif
public class when_an_aggregate_is_created : SpecificationBase
{
private Guid _aggregateId;
private TestAggregate _testAggregate;
protected override void Because()
{
_aggregateId = Guid.NewGuid();
_testAggregate = new TestAggregate(_aggregateId, "Test");
}
[Fact]
public void should_have_raised_creation_event()
{
_testAggregate.HasRaisedEvent<TestAggregateCreatedEvent>().Should().BeTrue();
}
[Fact]
public void creation_event_should_carry_the_correct_data()
{
var evt = _testAggregate.LastRaisedEvent<TestAggregateCreatedEvent>();
evt.Id.Should().Be(_aggregateId);
evt.Name.Should().Be("Test");
}
[Fact]
public void should_have_name()
{
_testAggregate.Name.Should().Be("Test");
}
[Fact]
public void aggregate_version_should_be_one()
{
_testAggregate.Version.Should().Be(1);
}
}
public class when_updating_an_aggregate : SpecificationBase
{
private Guid _aggregateId;
private TestAggregate _testAggregate;
protected override void Context()
{
_aggregateId = Guid.NewGuid();
_testAggregate = new TestAggregate(_aggregateId, "Test");
}
protected override void Because()
{
_testAggregate.ChangeName("UpdatedTest");
}
[Fact]
public void should_have_raised_an_update_event()
{
_testAggregate.HasRaisedEvent<NameChangedEvent>().Should().BeTrue();
}
[Fact]
public void creation_event_should_carry_the_correct_data()
{
var evt = _testAggregate.LastRaisedEvent<NameChangedEvent>();
evt.Id.Should().Be(_aggregateId);
evt.Name.Should().Be("UpdatedTest");
}
[Fact]
public void name_change_should_be_applied()
{
_testAggregate.Name.Should().Be("UpdatedTest");
}
[Fact]
public void applying_events_automatically_increments_version()
{
_testAggregate.Version.Should().Be(2);
}
}
}