public async Task HttpContextGetListOfProjectsEnrollmentOfUserByUserIdAsync() { await CreateUserAndMockingHttpContextToReturnAccessToken(); var responseProjects = Task.FromResult(_stringConstant.ProjectDetailsForAdminFromOauth); var requestUrl = string.Format(_stringConstant.FirstAndSecondIndexStringFormat, _stringConstant.DetailsAndSlashForUrl, _stringConstant.StringIdForTest); _mockHttpClient.Setup(x => x.GetAsync(_stringConstant.ProjectUrl, requestUrl, _stringConstant.AccessTokenForTest, _stringConstant.Bearer)).Returns(responseProjects); var result = await _oauthCallHttpContextRepository.GetListOfProjectsEnrollmentOfUserByUserIdAsync(_stringConstant.StringIdForTest); Assert.NotEqual(result.Count, 0); }
/// <summary> /// Method to return the list of projects depending on the role of the logged in user /// </summary> /// <param name="userId">userId of user</param> /// <returns>List of projects</returns> public async Task <IEnumerable <ProjectAc> > GetProjectsAsync(string userId) { //Getting the details of the logged in user from Oauth server User loginUser = await _oauthCallsRepository.GetUserByEmployeeIdAsync(userId); List <ProjectAc> projects = new List <ProjectAc>(); if (loginUser.Role.Equals(_stringConstant.Admin)) { projects = await _oauthCallsRepository.GetAllProjectsAsync(); } else { projects = await _oauthCallsRepository.GetListOfProjectsEnrollmentOfUserByUserIdAsync(loginUser.Id); } return(projects); }