public void Search_Hierarchy_FindsExpectedComponents() { // Arrange var parentId = "parent-1"; var component = new Component("myName", null, null) { Id = parentId, Type = "myType", Fields = new Dictionary <string, object> { ["k1"] = 99 } }; _tagServiceMock.Setup(ts => ts.GetAllTags(null)) .Returns(Task.FromResult(new List <Tag> { new Tag("tag1", null, null) { Components = new List <string> { parentId } } })); _componentServiceMock.Setup(cs => cs.GetAllComponents(null)) .Returns(Task.FromResult(new List <Component> { component })); var spec = new SearchSpec(null); var tagSearch = new TagSearchSpecElement(); tagSearch.AddTags(new List <string> { "tag1" }); spec.AddElement(tagSearch); var typeAndFieldSearchSpec = new ComponentTypeAndFieldSearchSpecElement { ComponentType = "myType" }; typeAndFieldSearchSpec.AddFieldFilter("k1", 99); spec.AddElement(typeAndFieldSearchSpec); var searcher = GetSearcher(); // Act var found = searcher.Search(spec).Result; // Assert Assert.Single(found); Assert.Equal("myName", found.Single().Name); }
public void Search_OneSearchTerm_FindsExpectedComponents() { // Arrange var comp = new Component("my-comp", null, null) { Id = "my-id", Type = "MyType" }; var spec = new SearchSpec(null); spec.AddElement(new ComponentTypeAndFieldSearchSpecElement { ComponentType = "MyType" }); _tagServiceMock.Setup(ts => ts.GetAllTags(null)) .Returns(Task.FromResult(new List <Tag>())); _componentServiceMock.Setup(cs => cs.GetAllComponents(null)) .Returns(Task.FromResult(new List <Component> { comp })); var searcher = GetSearcher(); // Act var found = searcher.Search(spec).Result; // Assert Assert.Single(found); }
private static SearchSpec GetSearchSpecForServiceBusOrEventHubNamespace(string connectionString, string searchFolder) { var arr = connectionString.Split(';'); var endpoint = arr.Single(a => a.StartsWith("Endpoint=")); var entityPath = arr.Single(a => a.StartsWith("EntityPath=")); var spec = new SearchSpec(searchFolder); var namespaceElement = new ComponentTypeAndFieldSearchSpecElement(); namespaceElement.ComponentType = "ServiceBusNamespace"; namespaceElement.AddFieldFilter("uri", endpoint.Split('=')[1]); spec.AddElement(namespaceElement); var entityElement = new ComponentTypeAndFieldSearchSpecElement(); entityElement.Name = entityPath.Split('=')[1]; spec.AddElement(entityElement); return(spec); }
private void Search_IntegrationTest() { // Arrange var url = ""; var token = ""; var organization = ""; var client = new ArdoqClient(new HttpClient(), url, token, organization); var searcher = new ArdoqSearcher(client, new ConsoleLogger()); var tag = "integration-test"; var spec = new SearchSpec(null); var tagElement = new TagSearchSpecElement(); tagElement.AddTags(new List <string> { tag }); spec.AddElement(tagElement); // Act var results = searcher.Search(spec).Result; }
public void Search_HierarchyNoHits_ReturnsEmptyList() { // Arrange var parentId = "parent-1"; var childId = "child-1"; var parentComponent = new Component("parent", null, null) { Id = parentId, Type = "ParentType", Children = new List <string> { childId } }; var childComponent = new Component("child", null, null) { Id = childId, Type = "ChildType", Fields = new Dictionary <string, object> { ["k1"] = 66 } }; _tagServiceMock.Setup(ts => ts.GetAllTags(null)) .Returns(Task.FromResult(new List <Tag> { new Tag("tag1", null, null) { Components = new List <string> { parentId } } })); _componentServiceMock.Setup(cs => cs.GetAllComponents(null)) .Returns(Task.FromResult(new List <Component> { parentComponent, childComponent })); var spec = new SearchSpec(null); var tagSpec = new TagSearchSpecElement(); tagSpec.AddTags(new List <string> { "tag1" }); spec.AddElement(tagSpec); var typeAndFieldSearchSpec = new ComponentTypeAndFieldSearchSpecElement { ComponentType = "ChildType" }; typeAndFieldSearchSpec.AddFieldFilter("k1", 99); spec.AddElement(typeAndFieldSearchSpec); var searcher = GetSearcher(); // Act var found = searcher.Search(spec).Result; // Assert Assert.Empty(found); }