public async Task HandleAsync(OrganisationUserRequestCompletedEvent @event)
        {
            IEnumerable <OrganisationUser> activeOrganisationUsers = await dataAccess.FetchActiveOrganisationUsers(@event.OrganisationUser.OrganisationId);

            bool activeUsers = true;

            if (activeOrganisationUsers == null || !activeOrganisationUsers.Any())
            {
                activeUsers = false;
            }

            await emailService.SendOrganisationUserRequestCompleted(@event.OrganisationUser, activeUsers);
        }
Пример #2
0
        public async Task HandleAsync_GivenRequest_SendOrganisationUserRequestCompletedIsCalledWithCorrectParameters(bool activeUsers)
        {
            var request = A.Dummy <OrganisationUserRequestCompletedEvent>();
            var activeOrganisationUsers = new List <OrganisationUser>();

            if (activeUsers)
            {
                activeOrganisationUsers.Add(A.Fake <OrganisationUser>());
            }

            A.CallTo(() => dataAccess.FetchActiveOrganisationUsers(request.OrganisationUser.OrganisationId)).Returns(activeOrganisationUsers);

            await handler.HandleAsync(request);

            A.CallTo(() => emailService.SendOrganisationUserRequestCompleted(request.OrganisationUser, activeUsers)).MustHaveHappened(Repeated.Exactly.Once);
        }