private async Task RunStateMachine(Func <string, IStateMachine> getter, string innerXml)
        {
            var stateMachine = getter(innerXml);

            try
            {
                await StateMachineInterpreter.RunAsync(SessionId.New(), stateMachine, _eventChannel, _options);

                Assert.Fail("StateMachineQueueClosedException should be raised");
            }
            catch (StateMachineQueueClosedException)
            {
                //ignore
            }
        }
Example #2
0
        public async Task <(ICommandResult result, IReadOnlyList <IDomainEvent> events)> ExecuteAsync(RequestSession command, CancellationToken cancellationToken = default)
        {
            Schedule?schedule;

            try
            {
                schedule = Schedule.Create(command.StartTime, command.EndTime);
            }
            catch (ArgumentException e)
            {
                var result = new ValidationFailureCommandResult($"Schedule is invalid: {e.Message}.");
                result.AddValidationError(e.ParamName, e.Message);
                return(result, DomainEvent.None);
            }

            if (command.Speakers.Any())
            {
                var peopleExists = await Task.WhenAll(command.Speakers.Select(async s =>
                {
                    var name = await _personProjectionStore.GetNameAsync(s);
                    return(id: s, exists: name != null);
                }));

                ValidationFailureCommandResult?vfcr = null;
                foreach (var p in peopleExists.Where(p => !p.exists))
                {
                    vfcr ??= new ValidationFailureCommandResult("Speakers are invalid: unknown speakers");
                    vfcr.AddValidationError(nameof(RequestSession.Speakers), $"{p.id} is unknown");
                }

                if (vfcr != null)
                {
                    return(vfcr, DomainEvent.None);
                }
            }

            var session = new Session(SessionId.New(), command.Speakers, command.Title, command.Description, command.Tags, schedule, SessionStatus.Requested);

            await _sessionRepository.AddAsync(session).ConfigureAwait(false);

            return(new SuccessCommandResult(), new[] { new SessionRequested(session.Id) });
        }
Example #3
0
 public async Task CheckThat_ApprovingRequestedSession_IsSuccessAndSessionIsApproved()
 {
     var existingSession = new Session(SessionId.New(), Array.Empty <PersonId>(), "title", "description", Array.Empty <string>(), default, SessionStatus.Requested);
Example #4
0
 public void GivenSession(string title, SessionStatus status)
 {
     var session = new Core.Domain.PlanningContext.Entities.Session(SessionId.New(), Array.Empty <PersonId>(), title, string.Empty, Array.Empty <string>(), default, status);