Line data Source code
1 : using System;
2 : using Akka.Actor;
3 : using cdmdotnet.Logging;
4 : using Cqrs.Akka.Domain;
5 : using Cqrs.Akka.Events;
6 : using Cqrs.Authentication;
7 : using Cqrs.Events;
8 :
9 : namespace Cqrs.Akka.Tests.Unit.Events.Handlers
10 : {
11 : public class HelloWorldRepliedToEventHandler
12 : : IEventHandler<Guid, HelloWorldRepliedTo>
13 0 : {
14 : /// <summary>
15 : /// Instantiates the <see cref="HelloWorldRepliedToEventHandler"/> class registering any <see cref="ReceiveActor.Receive{T}(System.Func{T,System.Threading.Tasks.Task})"/> required.
16 : /// </summary>
17 1 : public HelloWorldRepliedToEventHandler(IAkkaAggregateResolver aggregateResolver)
18 : {
19 : AggregateResolver = aggregateResolver;
20 : }
21 :
22 : protected IAkkaAggregateResolver AggregateResolver { get; private set; }
23 :
24 : #region Implementation of IMessageHandler<in HelloWorldRepliedTo>
25 :
26 0 : public void Handle(HelloWorldRepliedTo message)
27 : {
28 : IActorRef item = AggregateResolver.ResolveActor<HelloWorldRepliedToEventHandlerActor>();
29 : bool result = item.Ask<bool>(message).Result;
30 : // item.Tell(message);
31 : }
32 :
33 : #endregion
34 : }
35 :
36 : public class HelloWorldRepliedToEventHandlerActor
37 : : AkkaEventHandler<Guid>
38 0 : {
39 : #region Implementation of IMessageHandler<in HelloWorldRepliedTo>
40 :
41 0 : public void Handle(HelloWorldRepliedTo message)
42 : {
43 : AkkaUnitTests.Step2Reached[message.CorrelationId] = true;
44 : }
45 :
46 : #endregion
47 :
48 0 : public HelloWorldRepliedToEventHandlerActor(ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper<Guid> authenticationTokenHelper)
49 : : base(logger, correlationIdHelper, authenticationTokenHelper)
50 : {
51 : Receive<HelloWorldRepliedTo>(@event => Execute(Handle, @event));
52 : }
53 : }
54 : }
|