-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added coverage for aggregate root. added circle ci config
- Loading branch information
Jeremy Stafford
committed
Feb 3, 2019
1 parent
8474ea3
commit 2a34c45
Showing
46 changed files
with
527 additions
and
2,465 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: microsoft/dotnet:2.2-sdk | ||
branches: | ||
only: | ||
- master | ||
steps: | ||
- checkout | ||
- run: | ||
name: Restore Packages | ||
command: dotnet restore src | ||
- run: | ||
name: Build Solution (should auto-pack) | ||
command: dotnet build src -c Release /p:BuildNumber=${CIRCLE_BUILD_NUM} | ||
- run: | ||
name: Run unit tests | ||
command: dotnet test src | ||
- run: | ||
name: Publish NuGet Packages | ||
command: dotnet nuget push src/**/bin/Release/**.nupkg --source https://api.nuget.org/v3/index.json --api-key ${PROV_NUGET_KEY} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Provausio.Practices.Tests/EventSourcing/AggregateEventTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Provausio.Practices.EventSourcing.Aggregate; | ||
using Xunit; | ||
|
||
namespace Provausio.Practices.Tests.EventSourcing | ||
{ | ||
public class AggregateEventTests | ||
{ | ||
[Fact] | ||
public void Create_GeneratesAnId() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var ev = AggregateEvent.Create<TestEvent1>(); | ||
|
||
Assert.NotEmpty(ev.Id.ToString()); | ||
Assert.NotNull(ev.Id); | ||
} | ||
} | ||
|
||
public class TestEvent1 : AggregateEvent | ||
{ | ||
|
||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
src/Provausio.Practices.Tests/EventSourcing/AggregateRootTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Provausio.Practices.EventSourcing.Aggregate; | ||
using Xunit; | ||
|
||
namespace Provausio.Practices.Tests.EventSourcing | ||
{ | ||
public class AggregateRootTests | ||
{ | ||
[Fact] | ||
public void Raise_QueuesEvent() | ||
{ | ||
// arrange | ||
|
||
// act | ||
var test = TestRoot.Create("foo", 1); | ||
|
||
// assert | ||
Assert.Equal(1, test.UncommittedEvents.Count); | ||
Assert.IsType<CreationEvent>(test.UncommittedEvents.First()); | ||
} | ||
|
||
[Fact] | ||
public void Raise_NewRoot_VersionIsNotIncremented() | ||
{ | ||
// arrange | ||
var test = TestRoot.Create("foo", 1); | ||
|
||
// act | ||
test.Action1(); | ||
|
||
// assert | ||
Assert.Equal(-1, test.Version); | ||
} | ||
|
||
[Fact] | ||
public void Raise_ExistingRoot_VersionIsIncremented() | ||
{ | ||
// arrange | ||
var eventStream = new List<AggregateEvent> | ||
{ | ||
new CreationEvent {Version = 0, RootId = "abc"}, | ||
new Action1Occured {Version = 1, RootId = "abc"}, | ||
new EntityCreated {Version = 2, RootId = "abc"} | ||
}; | ||
|
||
// act | ||
var test = new TestRoot() {Id = "abc"}; | ||
test.LoadFromStream(eventStream); | ||
|
||
// assert | ||
Assert.Equal(2, test.Version); | ||
} | ||
|
||
[Fact] | ||
public void LoadFromStream_BringsObjectToState() | ||
{ | ||
// arrange | ||
var id = Guid.NewGuid(); | ||
var test = new TestRoot { Id = id.ToString() }; | ||
var create = new CreationEvent { Id = id, RootId = id.ToString(), Version = 0, Prop1 = "foo", Prop2 = 1 }; | ||
var action1 = new Action1Occured { RootId = id.ToString(), Version = 1 }; | ||
|
||
// act | ||
test.LoadFromStream(new AggregateEvent[] { create, action1 }); | ||
|
||
// assert | ||
Assert.Equal(0, test.UncommittedEvents.Count); | ||
Assert.Equal(id.ToString(), test.Id); | ||
Assert.True(test.Action1Occured); | ||
Assert.Equal(1, test.Version); | ||
} | ||
|
||
[Fact] | ||
public void CreateEntity_CreatesEntity() | ||
{ | ||
// arrange | ||
var test = TestRoot.Create("foo", 1); | ||
|
||
// act | ||
test.CreateEntity("entity-foo"); | ||
|
||
// assert | ||
Assert.Equal("entity-foo", test.EntityProp); | ||
} | ||
|
||
[Fact] | ||
public void UpdateEntity_ProxiesEventsToEntity() | ||
{ | ||
// arrange | ||
var test = TestRoot.Create("foo", 1); | ||
test.CreateEntity("entity-foo"); | ||
|
||
// act | ||
test.UpdateEntity("entity-bar"); | ||
|
||
// assert | ||
Assert.Equal("entity-bar", test.EntityProp); | ||
} | ||
} | ||
} |
86 changes: 0 additions & 86 deletions
86
src/Provausio.Practices.Tests/EventSourcing/AggregateTests.cs
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
src/Provausio.Practices.Tests/EventSourcing/AttributeAsAssemblyQualifiednameStrategyTests.cs
This file was deleted.
Oops, something went wrong.
52 changes: 0 additions & 52 deletions
52
src/Provausio.Practices.Tests/EventSourcing/ByAssemblyQualifiedTypeNameStrategyTests.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.