コード例 #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]
            [RequestBodyType(typeof(GetGroupActivityCredentialsRequest), "Get Group Activity Credentials")] GetGroupActivityCredentialsRequest req,
            CancellationToken cancellationToken)
        {
            try
            {
                GetGroupActivityCredentialsResponse response = await _mediator.Send(req, cancellationToken);

                return(new OkObjectResult(ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> .CreateSuccessfulResponse(response)));
            }
            catch (Exception ex)
            {
                _logger.LogErrorAndNotifyNewRelic($"Unhandled error in GetGroupActivityCredentials", ex);
                return(new ObjectResult(ResponseWrapper <GetGroupActivityCredentialsResponse, GroupServiceErrorCode> .CreateUnsuccessfulResponse(GroupServiceErrorCode.InternalServerError, "Internal Error"))
                {
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }
コード例 #2
0
        public async Task WhenCreatedByUserIsSameAsVolunteerUserID_ReturnsSuccess(GroupRoles role)
        {
            _updateJobStatusOutcome = UpdateJobStatusOutcome.Success;
            _request = new PutUpdateJobStatusToInProgressRequest
            {
                CreatedByUserID = 1,
                JobID           = 1,
                VolunteerUserID = 1
            };
            _getUserGroupsReponse = new GetUserGroupsResponse()
            {
                Groups = new List <int>()
                {
                    1
                }
            };

            _getGroupsForJobResponse = new List <int>()
            {
                1
            };

            _referringGroupId = 1;

            Dictionary <int, List <int> > roles = new Dictionary <int, List <int> >();

            roles.Add(1, new List <int>()
            {
                (int)role
            });

            _getJobDetailsResponse = new GetJobDetailsResponse()
            {
                JobSummary = new JobSummary()
                {
                    JobID           = 1,
                    SupportActivity = SupportActivities.Shopping
                }
            };

            _getGroupMemberResponse = new GetGroupMemberResponse()
            {
                UserInGroup = new UserInGroup()
                {
                    GroupId    = 1,
                    UserId     = 1,
                    GroupRoles = new List <GroupRoles>()
                    {
                        GroupRoles.Member
                    },
                    ValidCredentials = new List <int>()
                    {
                        -1
                    }
                }
            };

            _getGroupActivityCredentialsResponse = new GetGroupActivityCredentialsResponse()
            {
                CredentialSets = new List <List <int> > {
                    new List <int>()
                    {
                        -1
                    }
                }
            };

            _hasPermission = true;

            var response = await _classUnderTest.Handle(_request, CancellationToken.None);

            _repository.Verify(x => x.JobIsInProgressWithSameVolunteerUserId(It.IsAny <int>(), It.IsAny <int?>()), Times.Once);
            _groupService.Verify(x => x.GetUserGroups(It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Once);
            _groupService.Verify(x => x.GetGroupMember(It.IsAny <GetGroupMemberRequest>()), Times.Once);
            _groupService.Verify(x => x.GetGroupActivityCredentials(It.IsAny <GetGroupActivityCredentialsRequest>()), Times.Once);
            _repository.Verify(x => x.GetGroupsForJobAsync(It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Once);
            _repository.Verify(x => x.GetReferringGroupIDForJobAsync(It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Once);
            _groupService.Verify(x => x.GetGroupMember(It.IsAny <GetGroupMemberRequest>()), Times.Once);
            _groupService.Verify(x => x.GetGroupActivityCredentials(It.IsAny <GetGroupActivityCredentialsRequest>()), Times.Once);
            _repository.Verify(x => x.UpdateJobStatusInProgressAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <CancellationToken>()), Times.Once);
            _communicationService.Verify(x => x.RequestCommunication(It.IsAny <RequestCommunicationRequest>(), It.IsAny <CancellationToken>()), Times.Once);
            Assert.AreEqual(UpdateJobStatusOutcome.Success, response.Outcome);
        }