public async Task GetDiscussions_CommentReturned_NoCommentReturned()
        {
            // Arrange
            int itemId      = 1;
            int projectId   = 1;
            var discussions = new List <Discussion>();
            var reviews     = new List <ThreadReviewTrace>()
            {
                new ThreadReviewTrace()
                {
                    ThreadId = 1, ReviewId = 1
                }
            };
            var returnResult = new Tuple <IEnumerable <Discussion>, IEnumerable <ThreadReviewTrace> >(discussions, reviews);

            _cxn.SetupQueryMultipleAsync("GetItemDiscussions", new Dictionary <string, object> {
                { "ItemId", itemId }
            }, returnResult);
            _cxn.SetupQueryAsync("GetItemDiscussionStates", new Dictionary <string, object> {
                { "ItemId", itemId }
            }, new List <DiscussionState>());

            // Act
            var result = (await _discussionsRepository.GetDiscussions(itemId, projectId)).ToList();

            // Assert
            Assert.AreEqual(0, result.Count);
        }
Beispiel #2
0
        private static IItemSearchRepository CreateFullTextSearchRepository <T>(
            FullTextSearchCriteria searchCriteria,
            ICollection <T> queryResult,
            ICollection <int?> queryResult2 = null)
        {
            var connectionWrapper = new SqlConnectionWrapperMock();

            connectionWrapper.SetupQueryAsync("SearchFullText",
                                              new Dictionary <string, object>
            {
                { "predefineds", SqlItemSearchRepository.Predefineds },
                { "page", Page },
                { "pageSize", PageSize },
                { "maxItems", MaxItems },
            },
                                              queryResult);
            connectionWrapper.SetupQueryMultipleAsync("SearchFullTextMetaData",
                                                      new Dictionary <string, object>
            {
                { "predefineds", SqlItemSearchRepository.Predefineds },
            },
                                                      new Tuple <IEnumerable <T>, IEnumerable <int?> >(queryResult, queryResult2));
            if (searchCriteria.ItemTypeIds != null)
            {
                connectionWrapper.SetupQueryAsync("SearchFullTextByItemTypes",
                                                  new Dictionary <string, object>
                {
                    { "predefineds", SqlItemSearchRepository.Predefineds },
                    { "page", Page },
                    { "pageSize", PageSize },
                    { "maxItems", MaxItems },
                    { "itemTypeIds", SqlConnectionWrapper.ToDataTable(searchCriteria.ItemTypeIds) }
                },
                                                  queryResult);
                connectionWrapper.SetupQueryMultipleAsync("SearchFullTextByItemTypesMetaData",
                                                          new Dictionary <string, object>
                {
                    { "predefineds", SqlItemSearchRepository.Predefineds },
                    { "itemTypeIds", SqlConnectionWrapper.ToDataTable(searchCriteria.ItemTypeIds) }
                },
                                                          new Tuple <IEnumerable <T>, IEnumerable <int?> >(queryResult, queryResult2));
            }

            var configuration = new Mock <ISearchConfiguration>();

            configuration.Setup(c => c.MaxItems).Returns(MaxItems.ToStringInvariant());
            configuration.Setup(c => c.MaxSearchableValueStringSize).Returns(MaxSearchableValueStringSize.ToStringInvariant());

            return(new SqlItemSearchRepository(connectionWrapper.Object, configuration.Object));
        }
        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 #4
0
        private void InitRepository(IEnumerable <SqlProjectMetaRepository.PropertyTypeVersion> ptVersions,
                                    IEnumerable <SqlProjectMetaRepository.ItemTypeVersion> itVersions,
                                    IEnumerable <SqlProjectMetaRepository.ItemTypePropertyTypeMapRecord> itptMap)
        {
            SqlProjectMetaRepository.ProjectVersion[] project = { new SqlProjectMetaRepository.ProjectVersion {
                                                                      IsAccesible = true
                                                                  } };
            _cxn.SetupQueryAsync <SqlProjectMetaRepository.ProjectVersion>("GetInstanceProjectById",
                                                                           new Dictionary <string, object> {
                { "projectId", _projectId }, { "userId", _userId }
            }, project);

            var mockResult = Tuple.Create(ptVersions, itVersions, itptMap);

            _cxn.SetupQueryMultipleAsync("GetProjectCustomTypes",
                                         new Dictionary <string, object> {
                { "projectId", _projectId }, { "revisionId", ServiceConstants.VersionHead }
            },
                                         mockResult);
        }