diff --git a/build/azure-pipelines-release-ci-cd.yaml b/build/azure-pipelines-release-ci-cd.yaml
index 485361ce..cca2d489 100644
--- a/build/azure-pipelines-release-ci-cd.yaml
+++ b/build/azure-pipelines-release-ci-cd.yaml
@@ -71,4 +71,11 @@ jobs:
displayName: 'Publish Artifact Source'
inputs:
PathtoPublish: '$(Agent.BuildDirectory)'
- ArtifactName: Source
\ No newline at end of file
+ ArtifactName: Source
+
+ - task: GitHubRelease@0
+ displayName: 'GitHub release (create)'
+ inputs:
+ gitHubConnection: 'Akkatecture-GitHub'
+ tagSource: manual
+ tag: $(Build.BuildNumber)
\ No newline at end of file
diff --git a/src/Akkatecture.Clustering/Akkatecture.Clustering.csproj b/src/Akkatecture.Clustering/Akkatecture.Clustering.csproj
index dca19e01..d0b348fc 100644
--- a/src/Akkatecture.Clustering/Akkatecture.Clustering.csproj
+++ b/src/Akkatecture.Clustering/Akkatecture.Clustering.csproj
@@ -28,7 +28,11 @@
true
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
-
+
+
+ NU5104
+
+
diff --git a/src/Akkatecture.Clustering/Dispatchers/ShardedAggregateSagaDispatcher.cs b/src/Akkatecture.Clustering/Dispatchers/ShardedAggregateSagaDispatcher.cs
index 1e6202a2..c8340e3d 100644
--- a/src/Akkatecture.Clustering/Dispatchers/ShardedAggregateSagaDispatcher.cs
+++ b/src/Akkatecture.Clustering/Dispatchers/ShardedAggregateSagaDispatcher.cs
@@ -65,7 +65,7 @@ protected virtual bool Dispatch(IDomainEvent domainEvent)
{
AggregateSagaManager.Tell(domainEvent);
- Logger.Debug($"{GetType().PrettyPrint()} just dispatched {domainEvent.GetType().PrettyPrint()} to {AggregateSagaManager}");
+ Logger.Debug("{0} just dispatched {1} to {2}",GetType().PrettyPrint(),domainEvent.GetType().PrettyPrint(),AggregateSagaManager.Path.Name);
return true;
}
diff --git a/src/Akkatecture.TestFixture/Aggregates/AggregateFixture.cs b/src/Akkatecture.TestFixture/Aggregates/AggregateFixture.cs
index fa2ea68a..2ca6ecbd 100644
--- a/src/Akkatecture.TestFixture/Aggregates/AggregateFixture.cs
+++ b/src/Akkatecture.TestFixture/Aggregates/AggregateFixture.cs
@@ -43,7 +43,8 @@ public class AggregateFixture : IFixtureArranger For(TIdentity aggregateId)
if(aggregateId == null)
throw new ArgumentNullException(nameof(aggregateId));
- if(!AggregateTestProbe.IsNobody())
- throw new InvalidOperationException(nameof(AggregateTestProbe));
+ if(!AggregateEventTestProbe.IsNobody())
+ throw new InvalidOperationException(nameof(AggregateEventTestProbe));
AggregateId = aggregateId;
- AggregateTestProbe = _testKit.CreateTestProbe("aggregate-probe");
+ AggregateEventTestProbe = _testKit.CreateTestProbe("aggregate-event-test-probe");
+ AggregateReplyTestProbe = _testKit.CreateTestProbe("aggregate-reply-test-probe");
AggregateProps = Props.Create(args: aggregateId);
AggregateRef = ActorRefs.Nobody;
UsesAggregateManager = false;
@@ -76,11 +78,14 @@ public IFixtureArranger Using(
{
if(aggregateId == null)
throw new ArgumentNullException(nameof(aggregateId));
- if(!AggregateTestProbe.IsNobody())
- throw new InvalidOperationException(nameof(AggregateTestProbe));
+ if(!AggregateEventTestProbe.IsNobody())
+ throw new InvalidOperationException(nameof(AggregateEventTestProbe));
+ if(!AggregateReplyTestProbe.IsNobody())
+ throw new InvalidOperationException(nameof(AggregateReplyTestProbe));
AggregateId = aggregateId;
- AggregateTestProbe = _testKit.CreateTestProbe("aggregate-probe");
+ AggregateEventTestProbe = _testKit.CreateTestProbe("aggregate-event-test-probe");
+ AggregateReplyTestProbe = _testKit.CreateTestProbe("aggregate-reply-test-probe");
AggregateRef = _testKit.Sys.ActorOf(Props.Create(aggregateManagerFactory), "aggregate-manager");
UsesAggregateManager = false;
AggregateProps = Props.Empty;
@@ -90,7 +95,7 @@ public IFixtureArranger Using(
public IFixtureExecutor GivenNothing()
{
- if (!UsesAggregateManager && AggregateRef == ActorRefs.Nobody)
+ if (!UsesAggregateManager && AggregateRef.IsNobody())
AggregateRef = _testKit.Sys.ActorOf(AggregateProps, AggregateId.Value);
return this;
@@ -115,7 +120,7 @@ public IFixtureExecutor Given(params ICommand Given(params ICommand When(params ICommand When(params ICommand AndWhen(params ICommand ThenExpect(Predicate aggregateEventPredicate = null)
- where TAggregateEvent : IAggregateEvent
+ where TAggregateEvent : class, IAggregateEvent
{
- _testKit.Sys.EventStream.Subscribe(AggregateTestProbe, typeof(DomainEvent));
+ _testKit.Sys.EventStream.Subscribe(AggregateEventTestProbe, typeof(IDomainEvent));
if(aggregateEventPredicate == null)
- AggregateTestProbe.ExpectMsg>();
+ AggregateEventTestProbe.ExpectMsg>();
else
- AggregateTestProbe.ExpectMsg>(x => aggregateEventPredicate(x.AggregateEvent));
+ AggregateEventTestProbe.ExpectMsg>(x => aggregateEventPredicate(x.AggregateEvent));
return this;
}
+
+ public IFixtureAsserter ThenExpectReply(Predicate aggregateReplyPredicate = null)
+ {
+ AggregateReplyTestProbe.ExpectMsg(aggregateReplyPredicate);
+ return this;
+ }
- public IFixtureAsserter ThenExpectDomainEvent(Predicate> domainEventPredicate = null)
- where TAggregateEvent : IAggregateEvent
+ public IFixtureAsserter ThenExpectDomainEvent(Predicate> domainEventPredicate = null)
+ where TAggregateEvent : class, IAggregateEvent
{
- _testKit.Sys.EventStream.Subscribe(AggregateTestProbe, typeof(DomainEvent));
+ _testKit.Sys.EventStream.Subscribe(AggregateEventTestProbe, typeof(IDomainEvent));
if(domainEventPredicate == null)
- AggregateTestProbe.ExpectMsg>();
+ AggregateEventTestProbe.ExpectMsg>();
else
- AggregateTestProbe.ExpectMsg>(domainEventPredicate);
+ AggregateEventTestProbe.ExpectMsg>(domainEventPredicate);
return this;
}
@@ -190,14 +201,14 @@ private void InitializeEventJournal(TIdentity aggregateId, params IAggregateEven
writes[i] = new AtomicWrite(new Persistent(committedEvent, i+1, aggregateId.Value, string.Empty, false, ActorRefs.NoSender, writerGuid));
}
var journal = Persistence.Instance.Apply(_testKit.Sys).JournalFor(null);
- journal.Tell(new WriteMessages(writes, AggregateTestProbe.Ref, 1));
+ journal.Tell(new WriteMessages(writes, AggregateEventTestProbe.Ref, 1));
- AggregateTestProbe.ExpectMsg();
+ AggregateEventTestProbe.ExpectMsg();
for (var i = 0; i < events.Length; i++)
{
var seq = i;
- AggregateTestProbe.ExpectMsg(x =>
+ AggregateEventTestProbe.ExpectMsg(x =>
x.Persistent.PersistenceId == aggregateId.ToString() &&
x.Persistent.Payload is CommittedEvent> &&
x.Persistent.SequenceNr == (long) seq+1);
@@ -208,12 +219,12 @@ private void InitializeSnapshotStore(TIdentity aggregateId,
where TAggregateSnapshot : IAggregateSnapshot
{
var snapshotStore = Persistence.Instance.Apply(_testKit.Sys).SnapshotStoreFor(null);
- var committedSnapshot = new ComittedSnapshot(aggregateId, aggregateSnapshot, new SnapshotMetadata(), DateTimeOffset.UtcNow, sequenceNumber);
+ var committedSnapshot = new CommittedSnapshot(aggregateId, aggregateSnapshot, new SnapshotMetadata(), DateTimeOffset.UtcNow, sequenceNumber);
var metadata = new AkkaSnapshotMetadata(aggregateId.ToString(), sequenceNumber);
- snapshotStore.Tell(new SaveSnapshot(metadata, committedSnapshot), AggregateTestProbe.Ref);
+ snapshotStore.Tell(new SaveSnapshot(metadata, committedSnapshot), AggregateEventTestProbe.Ref);
- AggregateTestProbe.ExpectMsg(x =>
+ AggregateEventTestProbe.ExpectMsg(x =>
x.Metadata.SequenceNr == sequenceNumber &&
x.Metadata.PersistenceId == aggregateId.ToString());
diff --git a/src/Akkatecture.TestFixture/Aggregates/IFixtureAsserter.cs b/src/Akkatecture.TestFixture/Aggregates/IFixtureAsserter.cs
index 1f1b2611..900ac1a2 100644
--- a/src/Akkatecture.TestFixture/Aggregates/IFixtureAsserter.cs
+++ b/src/Akkatecture.TestFixture/Aggregates/IFixtureAsserter.cs
@@ -35,9 +35,11 @@ public interface IFixtureAsserter
{
IFixtureAsserter AndWhen(params ICommand[] commands);
IFixtureAsserter ThenExpect(Predicate aggregateEventPredicate = null)
- where TAggregateEvent : IAggregateEvent;
+ where TAggregateEvent : class, IAggregateEvent;
+
+ IFixtureAsserter ThenExpectReply(Predicate aggregateReply = null);
- IFixtureAsserter ThenExpectDomainEvent(Predicate> domainEventPredicate = null)
- where TAggregateEvent : IAggregateEvent;
+ IFixtureAsserter ThenExpectDomainEvent(Predicate> domainEventPredicate = null)
+ where TAggregateEvent : class, IAggregateEvent;
}
}
\ No newline at end of file
diff --git a/src/Akkatecture.TestFixture/Akkatecture.TestFixture.csproj b/src/Akkatecture.TestFixture/Akkatecture.TestFixture.csproj
index 3ee140a8..37787c40 100644
--- a/src/Akkatecture.TestFixture/Akkatecture.TestFixture.csproj
+++ b/src/Akkatecture.TestFixture/Akkatecture.TestFixture.csproj
@@ -18,7 +18,7 @@
bdd style test fixtures for akkatecture
- akka cqrs es eventsourcing tdd actors testing actor-model
+ akka cqrs es eventsourcing tdd bdd actors testing actor-model
git
https://github.com/Lutando/Akkatecture
MIT
diff --git a/src/Akkatecture/Aggregates/AggregateManager.cs b/src/Akkatecture/Aggregates/AggregateManager.cs
index 2421b680..0cccfb59 100644
--- a/src/Akkatecture/Aggregates/AggregateManager.cs
+++ b/src/Akkatecture/Aggregates/AggregateManager.cs
@@ -60,7 +60,7 @@ protected AggregateManager()
protected virtual bool Dispatch(TCommand command)
{
- Logger.Info($"{GetType().PrettyPrint()} received {command.GetType().PrettyPrint()}");
+ Logger.Info("{0} received {1}", GetType().PrettyPrint(),command.GetType().PrettyPrint());
var aggregateRef = FindOrCreate(command.AggregateId);
@@ -72,7 +72,7 @@ protected virtual bool Dispatch(TCommand command)
protected virtual bool ReDispatch(TCommand command)
{
- Logger.Info($"{GetType().PrettyPrint()} as dead letter {command.GetType().PrettyPrint()}");
+ Logger.Info("{0} as dead letter {1}",GetType().PrettyPrint(), command.GetType().PrettyPrint());
var aggregateRef = FindOrCreate(command.AggregateId);
@@ -97,7 +97,7 @@ protected bool Handle(DeadLetter deadLetter)
protected virtual bool Terminate(Terminated message)
{
- Logger.Warning($"{typeof(TAggregate).PrettyPrint()}: {message.ActorRef.Path} has terminated.");
+ Logger.Warning("Aggregate of Type={0}, and Id={1}; has terminated.",typeof(TAggregate).PrettyPrint(), message.ActorRef.Path.Name);
Context.Unwatch(message.ActorRef);
return true;
}
@@ -106,7 +106,7 @@ protected virtual IActorRef FindOrCreate(TIdentity aggregateId)
{
var aggregate = Context.Child(aggregateId);
- if(Equals(aggregate, ActorRefs.Nobody))
+ if(aggregate.IsNobody())
{
aggregate = CreateAggregate(aggregateId);
}
@@ -129,7 +129,7 @@ protected override SupervisorStrategy SupervisorStrategy()
localOnlyDecider: x =>
{
- Logger.Warning($"[{GetType().PrettyPrint()}] Exception={x.ToString()} to be decided.");
+ Logger.Warning("{0} will supervise Exception={1} to be decided as {2}.",GetType().PrettyPrint(), x.ToString(), Directive.Restart);
return Directive.Restart;
});
}
diff --git a/src/Akkatecture/Aggregates/AggregateRoot.cs b/src/Akkatecture/Aggregates/AggregateRoot.cs
index d7052e64..05a38165 100644
--- a/src/Akkatecture/Aggregates/AggregateRoot.cs
+++ b/src/Akkatecture/Aggregates/AggregateRoot.cs
@@ -27,7 +27,9 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
+using System.Reflection;
using Akka.Actor;
using Akka.Event;
using Akka.Persistence;
@@ -55,11 +57,10 @@ public abstract class AggregateRoot : Re
private object PinnedReply { get; set; }
protected ILoggingAdapter Logger { get; }
- //TODO This should be private readonly.
- protected readonly IEventDefinitionService EventDefinitionService;
+ private readonly IEventDefinitionService _eventDefinitionService;
private readonly ISnapshotDefinitionService _snapshotDefinitionService;
private ISnapshotStrategy SnapshotStrategy { get; set; } = SnapshotNeverStrategy.Instance;
- protected TAggregateState State { get; }
+ public TAggregateState State { get; }
public IAggregateName Name => AggregateName;
public override string PersistenceId { get; }
public TIdentity Id { get; }
@@ -77,7 +78,7 @@ protected AggregateRoot(TIdentity id)
if ((this as TAggregate) == null)
{
throw new InvalidOperationException(
- $"Aggregate '{GetType().PrettyPrint()}' specifies '{typeof(TAggregate).PrettyPrint()}' as generic argument, it should be its own type");
+ $"Aggregate {Name} specifies Type={typeof(TAggregate).PrettyPrint()} as generic argument, it should be its own type.");
}
if (State == null)
@@ -86,15 +87,15 @@ protected AggregateRoot(TIdentity id)
{
State = (TAggregateState)Activator.CreateInstance(typeof(TAggregateState));
}
- catch
+ catch(Exception exception)
{
- Logger.Error($"Unable to activate State for {GetType()}");
+ Logger.Error(exception,"Unable to activate AggregateState of Type={0} for AggregateRoot of Name={1}",typeof(TAggregateState).PrettyPrint(), Name);
}
}
PinnedCommand = null;
- EventDefinitionService = new EventDefinitionService(Logger);
+ _eventDefinitionService = new EventDefinitionService(Logger);
_snapshotDefinitionService = new SnapshotDefinitionService(Logger);
Id = id;
PersistenceId = id.Value;
@@ -133,37 +134,86 @@ public IIdentity GetIdentity()
}
public virtual void Emit(TAggregateEvent aggregateEvent, IMetadata metadata = null)
- where TAggregateEvent : IAggregateEvent
+ where TAggregateEvent : class, IAggregateEvent
{
var committedEvent = From(aggregateEvent, Version, metadata);
Persist(committedEvent, ApplyCommittedEvent);
}
- public virtual void EmitAll(IEnumerable aggregateEvents, IMetadata metadata = null)
- where TAggregateEvent : IAggregateEvent
+
+
+ public virtual void EmitAll(params IAggregateEvent[] aggregateEvents)
{
- long version = Version;
- var comittedEvents = new List>();
+ var version = Version;
+
+ var committedEvents = new List
diff --git a/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTests.cs b/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTests.cs
index ed1aba36..b5b5b4da 100644
--- a/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTests.cs
+++ b/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTests.cs
@@ -21,6 +21,7 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+using System;
using System.ComponentModel;
using System.Threading.Tasks;
using Akka.Actor;
@@ -54,7 +55,7 @@ public AggregateTests()
public void InitialState_AfterAggregateCreation_TestCreatedEventEmitted()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
@@ -63,7 +64,7 @@ public void InitialState_AfterAggregateCreation_TestCreatedEventEmitted()
aggregateManager.Tell(command);
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.TestAggregateId.Equals(aggregateId) &&
x.Metadata.ContainsKey("some-key"));
}
@@ -75,7 +76,7 @@ public async Task SendingCommand_ToAggregateRoot_ShouldReplyWithProperMessage()
{
var eventProbe = CreateTestProbe("event-probe");
var commandProbe = CreateTestProbe("command-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
@@ -92,7 +93,7 @@ public async Task SendingCommand_ToAggregateRoot_ShouldReplyWithProperMessage()
public void EventContainerMetadata_AfterAggregateCreation_TestCreatedEventEmitted()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
@@ -101,7 +102,7 @@ public void EventContainerMetadata_AfterAggregateCreation_TestCreatedEventEmitte
aggregateManager.Tell(command);
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateIdentity.Equals(aggregateId)
&& x.IdentityType == typeof(TestAggregateId)
&& x.AggregateType == typeof(TestAggregate)
@@ -118,7 +119,7 @@ public void EventContainerMetadata_AfterAggregateCreation_TestCreatedEventEmitte
public void InitialState_AfterAggregateCreation_TestStateSignalled()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
@@ -129,7 +130,7 @@ public void InitialState_AfterAggregateCreation_TestStateSignalled()
aggregateManager.Tell(nextCommand);
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.LastSequenceNr == 1
&& x.AggregateEvent.Version == 1
&& x.AggregateEvent.AggregateState.TestCollection.Count == 0);
@@ -140,7 +141,7 @@ public void InitialState_AfterAggregateCreation_TestStateSignalled()
public void TestCommand_AfterAggregateCreation_TestEventEmitted()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
@@ -154,7 +155,7 @@ public void TestCommand_AfterAggregateCreation_TestEventEmitted()
aggregateManager.Tell(nextCommand);
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.Test.Equals(test));
}
@@ -163,7 +164,7 @@ public void TestCommand_AfterAggregateCreation_TestEventEmitted()
public void TestCommandTwice_AfterAggregateCreation_TestEventEmitted()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
@@ -184,12 +185,12 @@ public void TestCommandTwice_AfterAggregateCreation_TestEventEmitted()
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.Test.Equals(test)
&& x.AggregateSequenceNumber == 2);
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.Test.Equals(test2)
&& x.AggregateSequenceNumber == 3);
}
@@ -200,7 +201,7 @@ public void TestEventSourcing_AfterManyTests_TestStateSignalled()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
var commandId = CommandId.New;
@@ -223,21 +224,44 @@ public void TestEventSourcing_AfterManyTests_TestStateSignalled()
aggregateManager.Tell(reviveCommand);
-
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.LastSequenceNr == 6
&& x.AggregateEvent.Version == 6
&& x.AggregateEvent.AggregateState.TestCollection.Count == 5);
}
+ [Fact]
+ [Category(Category)]
+ public void TestEventMultipleEmitSourcing_AfterManyMultiCreateCommand_EventsEmitted()
+ {
+ var eventProbe = CreateTestProbe("event-probe");
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
+ var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
+
+ var aggregateId = TestAggregateId.New;
+ var commandId = CommandId.New;
+ var firstTest = new Test(TestId.New);
+ var secondTest = new Test(TestId.New);
+ var command = new CreateAndAddTwoTestsCommand(aggregateId, commandId, firstTest, secondTest);
+
+ aggregateManager.Tell(command);
+
+ eventProbe.ExpectMsg>();
+ eventProbe.ExpectMsg>();
+ eventProbe.ExpectMsg>();
+
+ }
+
[Fact]
[Category(Category)]
public void TestEventMultipleEmitSourcing_AfterManyMultiCommand_TestStateSignalled()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
var commandId = CommandId.New;
@@ -257,9 +281,17 @@ public void TestEventMultipleEmitSourcing_AfterManyMultiCommand_TestStateSignall
var reviveCommand = new PublishTestStateCommand(aggregateId);
aggregateManager.Tell(reviveCommand);
+ eventProbe
+ .ExpectMsg>();
+ eventProbe
+ .ExpectMsg>();
+ eventProbe
+ .ExpectMsg>();
+ eventProbe
+ .ExpectMsg>();
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.LastSequenceNr == 5
&& x.AggregateEvent.Version == 5
&& x.AggregateEvent.AggregateState.TestCollection.Count == 4);
@@ -271,7 +303,7 @@ public void TestEventMultipleEmitSourcing_AfterManyMultiCommand_TestStateSignall
public void TestSnapShotting_AfterManyTests_TestStateSignalled()
{
var eventProbe = CreateTestProbe("event-probe");
- Sys.EventStream.Subscribe(eventProbe, typeof(DomainEvent));
+ Sys.EventStream.Subscribe(eventProbe, typeof(IDomainEvent));
var aggregateManager = Sys.ActorOf(Props.Create(() => new TestAggregateManager()), "test-aggregatemanager");
var aggregateId = TestAggregateId.New;
var commandId = CommandId.New;
@@ -289,7 +321,7 @@ public void TestSnapShotting_AfterManyTests_TestStateSignalled()
}
eventProbe
- .ExpectMsg>(
+ .ExpectMsg>(
x => x.AggregateEvent.LastSequenceNr == 11
&& x.AggregateEvent.Version == 11
&& x.AggregateEvent.AggregateState.TestCollection.Count == 10
diff --git a/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTestsWithFixtures.cs b/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTestsWithFixtures.cs
index bd96b590..ebe6fb33 100644
--- a/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTestsWithFixtures.cs
+++ b/test/Akkatecture.Tests/UnitTests/Aggregates/AggregateTestsWithFixtures.cs
@@ -59,11 +59,14 @@ public void InitialEvent_AfterAggregateCreation_TestCreatedEventEmitted()
var aggregateId = TestAggregateId.New;
var commandId = CommandId.New;
var testId = TestId.New;
-
- this.FixtureFor(aggregateId)
+
+ this.FixtureFor(aggregateId)
.Given(new TestCreatedEvent(aggregateId), new TestAddedEvent(new Test(TestId.New)))
.When(new AddTestCommand(aggregateId, commandId, new Test(testId)))
- .ThenExpect(x => x.Test.Id == testId);
+ .ThenExpect(x => x.Test.Id == testId)
+ .ThenExpectReply(x => x.SourceId.Value == commandId.Value && x.Result.IsSuccess);
+
+
}
[Fact]
@@ -259,6 +262,23 @@ public void TestEventSourcing_AfterManyTests_TestStateSignalled()
&& x.AggregateEvent.AggregateState.TestCollection.Count == 5);
}
+ [Fact]
+ [Category(Category)]
+ public void TestEventMultipleEmitSourcing_AfterManyMultiCreateCommand_EventsEmitted()
+ {
+ var aggregateId = TestAggregateId.New;
+ var commandId = CommandId.New;
+ var firstTest = new Test(TestId.New);
+ var secondTest = new Test(TestId.New);
+
+ this.FixtureFor(aggregateId)
+ .GivenNothing()
+ .When(new CreateAndAddTwoTestsCommand(aggregateId, commandId, firstTest, secondTest))
+ .ThenExpectDomainEvent()
+ .ThenExpect()
+ .ThenExpect();
+ }
+
[Fact]
[Category(Category)]
public void TestEventMultipleEmitSourcing_AfterManyMultiCommand_TestStateSignalled()
diff --git a/test/Akkatecture.Tests/UnitTests/Fixtures/AggregateFixtureTests.cs b/test/Akkatecture.Tests/UnitTests/Fixtures/AggregateFixtureTests.cs
index 4f671ebf..c9251431 100644
--- a/test/Akkatecture.Tests/UnitTests/Fixtures/AggregateFixtureTests.cs
+++ b/test/Akkatecture.Tests/UnitTests/Fixtures/AggregateFixtureTests.cs
@@ -114,11 +114,11 @@ public void FixtureArrangerWithSnapshot_CanBeLoaded()
snapshotStore.Tell(new LoadSnapshot(aggregateIdentity.Value, new SnapshotSelectionCriteria(long.MaxValue, DateTime.MaxValue), long.MaxValue), receiverProbe.Ref);
receiverProbe.ExpectMsg(x =>
- x.Snapshot.Snapshot is ComittedSnapshot> &&
+ x.Snapshot.Snapshot is CommittedSnapshot> &&
x.Snapshot.Metadata.SequenceNr == snapshotSequenceNumber &&
x.Snapshot.Metadata.PersistenceId == aggregateIdentity.Value &&
x.Snapshot.Snapshot
- .As>>().AggregateSnapshot
+ .As>>().AggregateSnapshot
.As().Tests.Count == snapshot.Tests.Count &&
x.ToSequenceNr == long.MaxValue);
diff --git a/test/Akkatecture.Tests/UnitTests/Serialization/SerializationTests.cs b/test/Akkatecture.Tests/UnitTests/Serialization/SerializationTests.cs
index 9034e3ee..5d84f2cc 100644
--- a/test/Akkatecture.Tests/UnitTests/Serialization/SerializationTests.cs
+++ b/test/Akkatecture.Tests/UnitTests/Serialization/SerializationTests.cs
@@ -130,7 +130,7 @@ public void CommittedSnapshot_AfterSerialization_IsValidAfterDeserialization()
AggregateId = aggregateId.Value,
};
var committedEvent =
- new ComittedSnapshot(
+ new CommittedSnapshot(
aggregateId,
aggregateSnapshot,
snapshotMetadata,