Line data Source code
1 : using System;
2 : using cdmdotnet.Logging;
3 : using Cqrs.Akka.Domain;
4 : using Cqrs.Akka.Tests.Unit.Commands;
5 : using Cqrs.Akka.Tests.Unit.Events;
6 : using Cqrs.Authentication;
7 : using Cqrs.Configuration;
8 : using Cqrs.Domain;
9 :
10 : namespace Cqrs.Akka.Tests.Unit.Aggregates
11 : {
12 : public class HelloWorld : AkkaAggregateRoot<Guid>
13 0 : {
14 : public Guid Rsn
15 : {
16 : get { return Id; }
17 : private set { Id = value; }
18 : }
19 :
20 : public bool IsLogicallyDeleted {get; set;}
21 :
22 : protected IDependencyResolver DependencyResolver { get; private set; }
23 :
24 : // ReSharper disable UnusedMember.Local
25 : /// <summary>
26 : /// A constructor for the <see cref="Cqrs.Domain.Factories.IAggregateFactory"/>
27 : /// </summary>
28 : private HelloWorld()
29 : : base(null, null, null, null, null)
30 : {
31 : Receive<SayHelloWorldCommand>(command => Execute(SayHello, command));
32 : Receive<ReplyToHelloWorldCommand>(command => Execute(ReplyToHelloWorld, command));
33 : Receive<EndConversationCommand>(command => Execute(EndConversation, command));
34 : }
35 :
36 : /// <summary>
37 : /// A constructor for the <see cref="Cqrs.Domain.Factories.IAggregateFactory"/>
38 : /// </summary>
39 : private HelloWorld(IDependencyResolver dependencyResolver, ILogger logger)
40 : : this()
41 : {
42 : DependencyResolver = dependencyResolver;
43 : Logger = logger;
44 : UnitOfWork = DependencyResolver.Resolve<IUnitOfWork<Guid>>();
45 : Repository = DependencyResolver.Resolve<IAkkaAggregateRepository<Guid>>();
46 : CorrelationIdHelper = DependencyResolver.Resolve<ICorrelationIdHelper>();
47 : AuthenticationTokenHelper = DependencyResolver.Resolve<IAuthenticationTokenHelper<Guid>>();
48 : }
49 : // ReSharper restore UnusedMember.Local
50 :
51 0 : public HelloWorld(IDependencyResolver dependencyResolver, ILogger logger, Guid rsn)
52 : : this(dependencyResolver, logger)
53 : {
54 : Rsn = rsn;
55 : }
56 :
57 0 : public virtual void SayHello(SayHelloWorldCommand command)
58 : {
59 : SayHello();
60 : }
61 :
62 0 : public virtual void ReplyToHelloWorld(ReplyToHelloWorldCommand command)
63 : {
64 : ReplyToHelloWorld();
65 : }
66 :
67 0 : public virtual void EndConversation(EndConversationCommand command)
68 : {
69 : EndConversation();
70 : }
71 :
72 0 : public virtual void SayHello()
73 : {
74 : ApplyChange(new HelloWorldSaid { Id = Id });
75 : }
76 :
77 0 : public virtual void ReplyToHelloWorld()
78 : {
79 : ApplyChange(new HelloWorldRepliedTo { Id = Id });
80 : }
81 :
82 0 : public virtual void EndConversation()
83 : {
84 : ApplyChange(new ConversationEnded { Id = Id });
85 : }
86 : }
87 : }
|