public async Task GetCollectionContentSearchArtifactResults_AllSearchItemsExists_ReturnedSearchArtifactsResult()
        {
            // arrange
            var returnResult = new Tuple <IEnumerable <int>, IEnumerable <int> >(new int[] { _searchArtifactsResult.Total }, _searchArtifactsResult.ArtifactIds);

            _sqlConnectionWrapperMock.SetupQueryMultipleAsync(QueryBuilder.GetCollectionContentSearchArtifactResults(ScopeId, _pagination, true, UserId), null, returnResult, commandType: CommandType.Text);

            // act
            var result = await _searchEngineRepository.GetCollectionContentSearchArtifactResults(ScopeId, _pagination, true, UserId);

            // assert
            _sqlConnectionWrapperMock.Verify();
            Assert.AreEqual(_searchArtifactsResult.Total, result.Total);
            Assert.AreEqual(_searchArtifactsResult.ArtifactIds, result.ArtifactIds);
        }
Beispiel #2
0
        public async Task <SearchArtifactsResult> Search(int scopeId, Pagination pagination, ScopeType scopeType, bool includeDrafts, int userId, IDbTransaction transaction = null)
        {
            var artifactBasicDetails = await _sqlArtifactRepository.GetArtifactBasicDetails(scopeId, userId, transaction);

            if (artifactBasicDetails == null)
            {
                var errorMessage = I18NHelper.FormatInvariant(ErrorMessages.ArtifactNotFound, scopeId);
                throw new ResourceNotFoundException(errorMessage, ErrorCodes.ResourceNotFound);
            }

            if (artifactBasicDetails.PrimitiveItemTypePredefined != (int)ItemTypePredefined.ArtifactCollection)
            {
                throw new NotImplementedException(ErrorMessages.NotImplementedForNonCollectionArtifact);
            }

            if (scopeType == ScopeType.Descendants)
            {
                throw new NotImplementedException(ErrorMessages.NotImplementedForDescendantsScopeType);
            }

            return(await _searchEngineRepository.GetCollectionContentSearchArtifactResults(scopeId, pagination, includeDrafts, userId, transaction));
        }