예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }