-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
26 additions
and
24 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 |
---|---|---|
|
@@ -28,7 +28,9 @@ public void Aggregate_create_a_valid() | |
public void Aggregate_reconstruct_a_valid() | ||
{ | ||
var be = BusinessEntity.From(EntityTestId.GetNext(), VersionId.New()); | ||
var agg = BusinessEntityAggregateRoot.ReconstructFrom(be); | ||
|
||
var factory = new ObjectBasedAggregateFactory(); | ||
var agg = factory.Create(be); | ||
|
||
Assert.True(agg.IsValid); | ||
} | ||
|
@@ -41,10 +43,10 @@ public void Aggregate_EventBased_create_a_valid() | |
fixture.Register<Name>(()=> Name.From(fixture.Create<String>())); | ||
fixture.Register<Email>(()=> Email.From("[email protected]")); | ||
|
||
var name = fixture.Create<Name>(); | ||
var email = fixture.Create<Email>(); | ||
|
||
var agg = EventStreamBusinessEntityAggregateRoot.Create(EntityTestId.GetNext(), name, email); | ||
var addEntity = fixture.Create<AddEntityCommand>(); | ||
|
||
var factory = new EventBasedAggregateFactory(); | ||
var agg = factory.Create(addEntity); | ||
Assert.Equal(nameof(EventStreamBusinessEntityAggregateRoot),agg.GetChange().Name.Value); | ||
Assert.True(agg.IsValid); | ||
} | ||
|
@@ -62,7 +64,8 @@ public void Aggregate_EventBased_valid_Entity_create() | |
{ | ||
var fixture = new Fixture() | ||
.Customize(new AutoNSubstituteCustomization{ ConfigureMembers = true }); | ||
|
||
fixture.Register<string>(()=> "[email protected]"); | ||
|
||
var name = fixture.Create<string>(); | ||
var email = fixture.Create<string>(); | ||
|
||
|
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
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 |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
// | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
@@ -33,28 +32,23 @@ namespace DFlow.Tests.Supporting | |
{ | ||
public sealed class UpdateEntityEventBasedCommandHandler : CommandHandler<UpdateEntityCommand, CommandResult<Guid>> | ||
{ | ||
private IAggregateReconstructFactory<EventStreamBusinessEntityAggregateRoot, EventStream<EntityTestId>> | ||
_aggregationRoot; | ||
private IAggregateFactory<EventStreamBusinessEntityAggregateRoot, EventStream<EntityTestId>> | ||
_aggregateFactory; | ||
|
||
public UpdateEntityEventBasedCommandHandler(IDomainEventBus publisher, | ||
IAggregateReconstructFactory<EventStreamBusinessEntityAggregateRoot, EventStream<EntityTestId>> aggregateFactory) | ||
IAggregateFactory<EventStreamBusinessEntityAggregateRoot, EventStream<EntityTestId>> aggregateFactory) | ||
:base(publisher) | ||
{ | ||
_aggregationRoot = aggregateFactory; | ||
_aggregateFactory = aggregateFactory; | ||
} | ||
|
||
protected override Task<CommandResult<Guid>> ExecuteCommand(UpdateEntityCommand command, CancellationToken cancellationToken) | ||
{ | ||
// FIXME: remove this after clear my mind, i do need port the persistence event sourcing infrastructure now :) | ||
// var aggNew = _aggregationRoot | ||
// .ReconstructFrom(EntityTestId.GetNext(), Name.From("My name"), Email.From("[email protected]")); | ||
|
||
// var currentstream = aggOld.GetChange(); | ||
// var agg = EventStreamBusinessEntityAggregateRoot.Reconstruct(currentstream); | ||
|
||
var agg = _aggregationRoot | ||
.ReconstructFrom(EventStream<EntityTestId>.From(EntityTestId.Empty(), | ||
new AggregationName(), VersionId.Empty(), new ImmutableArray<IDomainEvent>())); | ||
var agg = _aggregateFactory.Create( | ||
EventStream<EntityTestId>.From(EntityTestId.Empty(), | ||
new AggregationName(), | ||
VersionId.Empty(), new ImmutableArray<IDomainEvent>()) | ||
); | ||
var isSucceed = agg.IsValid; | ||
var okId = Guid.Empty; | ||
|
||
|