Beispiel #1
0
        public void GetSearchResults_WhenScalarNameDoesNotHaveValue_ShouldNotReturnResult()
        {
            var mockResourceCatalog = new Mock <IResourceCatalog>();
            var mockResource        = new Mock <IResource>();

            mockResource.Setup(r => r.ResourceID).Returns(Guid.Empty);
            mockResource.Setup(r => r.ResourceName).Returns("Test Resource");
            mockResource.Setup(r => r.GetResourcePath(It.IsAny <Guid>())).Returns("Folder");
            mockResource.Setup(r => r.DataList).Returns(new StringBuilder("<DataList><scalar1 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"Input\" /><scalar2 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"Input\" /><Recset Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" ><Field1 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" /><Field2 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" /></Recset></DataList>"));
            mockResourceCatalog.Setup(res => res.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockResource.Object);
            mockResourceCatalog.Setup(res => res.GetResources(It.IsAny <Guid>())).Returns(new List <IResource>
            {
                mockResource.Object
            });
            var searchValue = new Common.Search.Search
            {
                SearchInput   = "bob",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected        = false,
                    IsToolTitleSelected  = false,
                    IsScalarNameSelected = true,
                }
            };

            var variableListSearcher = new VariableListSearcher(mockResourceCatalog.Object);
            var searchResults        = variableListSearcher.GetSearchResults(searchValue);

            Assert.AreEqual(0, searchResults.Count);
        }
Beispiel #2
0
        public void GetSearchResults_WhenRecsetNameHasValue_ShouldReturnResult()
        {
            var mockResourceCatalog = new Mock <IResourceCatalog>();
            var mockResource        = new Mock <IResource>();

            mockResource.Setup(r => r.ResourceID).Returns(Guid.Empty);
            mockResource.Setup(r => r.ResourceName).Returns("Test Resource");
            mockResource.Setup(r => r.GetResourcePath(It.IsAny <Guid>())).Returns("Folder");
            mockResource.Setup(r => r.DataList).Returns(new StringBuilder("<DataList><scalar1 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"Input\" /><scalar2 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"Input\" /><Recset Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" ><Field1 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" /><Field2 Description=\"\" IsEditable=\"True\" " +
                                                                          "ColumnIODirection=\"None\" /></Recset></DataList>"));
            mockResourceCatalog.Setup(res => res.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockResource.Object);
            mockResourceCatalog.Setup(res => res.GetResources(It.IsAny <Guid>())).Returns(new List <IResource>
            {
                mockResource.Object
            });
            var searchOptions = new SearchOptions();

            searchOptions.UpdateAllStates(false);
            searchOptions.IsRecSetNameSelected = true;
            var searchValue = new Common.Search.Search
            {
                SearchInput   = "set",
                SearchOptions = searchOptions
            };


            var variableListSearcher = new VariableListSearcher(mockResourceCatalog.Object);
            var searchResults        = variableListSearcher.GetSearchResults(searchValue);

            Assert.AreEqual(2, searchResults.Count);
            var searchResult = searchResults[0];

            Assert.AreEqual(Guid.Empty, searchResult.ResourceId);
            Assert.AreEqual("Recset", searchResult.Match);
            Assert.AreEqual("Test Resource", searchResult.Name);
            Assert.AreEqual("Folder", searchResult.Path);
            Assert.AreEqual(Common.Interfaces.Search.SearchItemType.RecordSet, searchResult.Type);
            searchResult = searchResults[1];
            Assert.AreEqual(Guid.Empty, searchResult.ResourceId);
            Assert.AreEqual("Recset", searchResult.Match);
            Assert.AreEqual("Test Resource", searchResult.Name);
            Assert.AreEqual("Folder", searchResult.Path);
            Assert.AreEqual(Common.Interfaces.Search.SearchItemType.RecordSet, searchResult.Type);
        }