private bool Execute(PoisonTestAggregateCommand command)
        {
            if (!IsNew)
            {
                Context.Stop(Self);
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
 private bool Execute(AddTestCommand command)
 {
     if (!IsNew)
     {
         Emit(new TestAddedEvent(command.Test));
         Reply(TestExecutionResult.SucceededWith(command.SourceId));
     }
     else
     {
         TestErrors++;
         Throw(new TestedErrorEvent(TestErrors));
         Reply(TestExecutionResult.FailedWith(command.SourceId));
     }
     return(true);
 }
        private bool Execute(ReceiveTestCommand command)
        {
            if (!IsNew)
            {
                Emit(new TestReceivedEvent(command.SenderAggregateId, command.TestToReceive));
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
        private bool Execute(CreateTestCommand command)
        {
            if (IsNew)
            {
                Emit(new TestCreatedEvent(command.AggregateId), new Metadata {
                    { "some-key", "some-value" }
                });
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
        private bool Execute(GiveTestCommand command)
        {
            if (!IsNew)
            {
                if (State.TestCollection.Any(x => x.Id == command.TestToGive.Id))
                {
                    Emit(new TestSentEvent(command.TestToGive, command.ReceiverAggregateId));
                    Reply(TestExecutionResult.SucceededWith(command.SourceId));
                }
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
        private bool Execute(AddFourTestsCommand command)
        {
            if (!IsNew)
            {
                var events = Enumerable
                             .Range(0, 4)
                             .Select(x => new TestAddedEvent(command.Test));

                EmitAll(events);
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                Reply(TestExecutionResult.FailedWith(command.SourceId));
            }
            return(true);
        }
Beispiel #7
0
        public bool Execute(CreateAndAddTwoTestsCommand command)
        {
            if (IsNew)
            {
                var createdEvent         = new TestCreatedEvent(command.AggregateId);
                var firstTestAddedEvent  = new TestAddedEvent(command.FirstTest);
                var secondTestAddedEvent = new TestAddedEvent(command.SecondTest);
                EmitAll(createdEvent, firstTestAddedEvent, secondTestAddedEvent);
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                ReplyFailure(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }
Beispiel #8
0
        public bool Execute(AddFourTestsCommand command)
        {
            if (!IsNew)
            {
                var events = Enumerable
                             .Range(0, 4)
                             .Select(x => new TestAddedEvent(command.Test));

                // ReSharper disable once CoVariantArrayConversion
                EmitAll(events.ToArray());
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                ReplyFailure(TestExecutionResult.FailedWith(command.SourceId));
            }
            return(true);
        }
Beispiel #9
0
        private bool Execute(CreateAndAddTwoTestsCommand command)
        {
            if (IsNew)
            {
                var createdEvent         = new TestCreatedEvent(command.AggregateId);
                var firstTestAddedEvent  = new TestAddedEvent(command.FirstTest);
                var secondTestAddedEvent = new TestAddedEvent(command.SecondTest);
                var events = Events(createdEvent, firstTestAddedEvent, secondTestAddedEvent);
                //EmitAll(events, new Metadata {{"some-key","some-value"}});
                EmitAll(createdEvent, firstTestAddedEvent, secondTestAddedEvent);
                Reply(TestExecutionResult.SucceededWith(command.SourceId));
            }
            else
            {
                TestErrors++;
                Throw(new TestedErrorEvent(TestErrors));
                ReplyFailure(TestExecutionResult.FailedWith(command.SourceId));
            }

            return(true);
        }