Example #1
0
        private static IItemSearchRepository CreateItemNameRepository <T>(
            ItemNameSearchCriteria searchCriteria,
            ICollection <T> queryResult,
            IArtifactPermissionsRepository artifactPermissionsRepository,
            IArtifactRepository artifactRepository)
        {
            var connectionWrapper = new SqlConnectionWrapperMock();
            var parameters        = new Dictionary <string, object>
            {
                { "userId", UserId },
                { "query", searchCriteria.Query },
                { "projectIds", SqlConnectionWrapper.ToDataTable(searchCriteria.ProjectIds) },
                { "maxSearchableValueStringSize", MaxSearchableValueStringSize },
                { "startOffset", StartOffset },
                { "pageSize", PageSize },
                { "excludedPredefineds", SqlConnectionWrapper.ToDataTable(SqlItemSearchRepository.GetExcludedPredefineds(searchCriteria)) }
            };

            if (searchCriteria.PredefinedTypeIds != null)
            {
                parameters.Add("predefinedTypeIds", SqlConnectionWrapper.ToDataTable(searchCriteria.PredefinedTypeIds));
            }

            connectionWrapper.SetupQueryAsync(
                "SearchItemNameByItemTypes",
                parameters,
                queryResult);

            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, artifactPermissionsRepository, artifactRepository));
        }
Example #2
0
        public void ExcludedPredefineds_DoNotShowArtifacts_CorrectResult()
        {
            // Arrange
            var searchCriteria = new ItemNameSearchCriteria
            {
                ShowArtifacts           = false,
                ShowBaselinesAndReviews = true,
                ShowCollections         = true
            };

            ItemTypePredefined[] expected =
            {
                ItemTypePredefined.Glossary,
                ItemTypePredefined.TextualRequirement,
                ItemTypePredefined.PrimitiveFolder,
                ItemTypePredefined.BusinessProcess,
                ItemTypePredefined.Actor,
                ItemTypePredefined.UseCase,
                ItemTypePredefined.DataElement,
                ItemTypePredefined.UIMockup,
                ItemTypePredefined.GenericDiagram,
                ItemTypePredefined.Document,
                ItemTypePredefined.Storyboard,
                ItemTypePredefined.DomainDiagram,
                ItemTypePredefined.UseCaseDiagram,
                ItemTypePredefined.Process
            };

            // Act
            var excludedPredefineds = SqlItemSearchRepository.GetExcludedPredefineds(searchCriteria);

            // Assert
            CollectionAssert.AreEquivalent(expected, excludedPredefineds.Cast <ItemTypePredefined>().ToList());
        }
Example #3
0
        public void GetQuery_WithDoubleQuotes_ReturnsResults()
        {
            // Arrange
            var query    = "O\"Conner";
            var expected = "\"O\"\"Conner\"";


            // Act
            var result = SqlItemSearchRepository.GetQuery(query);

            // Assert
            Assert.AreEqual(expected, result, "returned query parameter does not match expected");
        }
Example #4
0
        public void ExcludedPredefineds_DoNotShowCollections_CorrectResult()
        {
            // Arrange
            ItemTypePredefined[] expected =
            {
                ItemTypePredefined.CollectionFolder,
                ItemTypePredefined.ArtifactCollection
            };
            var searchCriteria = new ItemNameSearchCriteria
            {
                ShowArtifacts           = true,
                ShowBaselinesAndReviews = true,
                ShowCollections         = false
            };

            // Act
            var excludedPredefineds = SqlItemSearchRepository.GetExcludedPredefineds(searchCriteria);

            // Assert
            CollectionAssert.AreEquivalent(expected, excludedPredefineds.Cast <ItemTypePredefined>().ToList());
        }