예제 #1
0
        public void GetSearchResults_WhenTestNameHasValueAndResourceDoesNotExists_ShouldReturnEmptyResult()
        {
            var mockResourceCatalog = new Mock <IResourceCatalog>();

            mockResourceCatalog.Setup(res => res.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(() => null);

            var searchValue = new Common.Search.Search
            {
                SearchInput   = "Set",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected      = false,
                    IsTestNameSelected = true
                }
            };

            var mockTestCatalog = new Mock <ITestCatalog>();

            mockTestCatalog.Setup(t => t.FetchAllTests()).Returns(new List <IServiceTestModelTO>
            {
                new ServiceTestModelTO
                {
                    TestName = "Set Test"
                }
                ,
                new ServiceTestModelTO
                {
                    TestName = "Test set value"
                }
            });
            var searcher      = new TestSearcher(mockResourceCatalog.Object, mockTestCatalog.Object);
            var searchResults = searcher.GetSearchResults(searchValue);

            Assert.AreEqual(0, searchResults.Count);
        }
예제 #2
0
        public void GetSearchResults_WhenTestNameHasValue_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");
            mockResourceCatalog.Setup(res => res.GetResource(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockResource.Object);

            var searchValue = new Common.Search.Search
            {
                SearchInput   = "Set",
                SearchOptions = new SearchOptions
                {
                    IsAllSelected      = false,
                    IsTestNameSelected = true
                }
            };

            var mockTestCatalog = new Mock <ITestCatalog>();

            mockTestCatalog.Setup(t => t.FetchAllTests()).Returns(new List <IServiceTestModelTO>
            {
                new ServiceTestModelTO
                {
                    TestName = "Bob Test"
                },
                new ServiceTestModelTO
                {
                    TestName = "Set Test"
                }
                ,
                new ServiceTestModelTO
                {
                    TestName = "Test set value"
                }
            });
            var searcher      = new TestSearcher(mockResourceCatalog.Object, mockTestCatalog.Object);
            var searchResults = searcher.GetSearchResults(searchValue);

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

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