Ejemplo n.º 1
0
        public void Given_valid_search_request_When_search_users_Then_should_call_correct_methods()
        {
            //Given
            var target = CreateUserService();
            var searchCriteria = new SearchUsersRequest()
                                {
                                    CompanyId = 185674L, 
                                    ForenameLike = "Tyrion", 
                                    SurnameLike = "Lannister", 
                                    AllowedSiteIds = new List<long>() { 123L, 457L, 35473L }, 
                                    SiteId = 3453451L, 
                                    ShowDeleted = false, 
                                    MaximumResults = 1000
                                };
            var returnedUsers = new List<User>();

            _userRepo
                .Setup(x => x.Search(
                    searchCriteria.CompanyId,
                    searchCriteria.ForenameLike,
                    searchCriteria.SurnameLike, 
                    searchCriteria.AllowedSiteIds, 
                    searchCriteria.SiteId,
                    searchCriteria.ShowDeleted, 
                    searchCriteria.MaximumResults))
                .Returns(returnedUsers);

            //When
            target.Search(searchCriteria);

            //Then
            _userRepo.VerifyAll();
        }
Ejemplo n.º 2
0
        private SearchUsersRequest CreateUserSearchRequest()
        {
            var userSearchRequest = new SearchUsersRequest()
            {
                CompanyId = _companyId,
                ForenameLike = string.IsNullOrEmpty(_forename) ? null : _forename + "%",
                SurnameLike = string.IsNullOrEmpty(_surname) ? null : _surname + "%",
                SiteId = _groupSiteId,
                ShowDeleted = _showDeleted
            };

            return userSearchRequest;
        }
Ejemplo n.º 3
0
 public IEnumerable<UserDto> Search(SearchUsersRequest request)
 {
     var users = _userRepository.Search(request.CompanyId, request.ForenameLike, request.SurnameLike, request.AllowedSiteIds, request.SiteId, request.ShowDeleted, request.MaximumResults);
     return new UserDtoMapper().MapIncludingEmployeeAndSite(users);
 }