public void QueryNode_ConvertTokensIntoNodes_MultipleQueryResults() { // Arrange string indexPropertyToSearchOn = "term"; string searchValue = "searchValue"; int numToFind = 5; Action <Index>[] elementInspectors = new Action <Index> [numToFind]; void ElementInspectorFunction(Index e) { Assert.Equal(indexPropertyToSearchOn, e.Field); Assert.Equal(searchValue, e.Term); } List <Index> indices = new List <Index>(); for (int i = 0; i < numToFind; i++) { indices.AddRange(GetTestIQueryable(indexPropertyToSearchOn, searchValue)); elementInspectors[i] = ElementInspectorFunction; } IQueryable <Index> queryable = indices.AsQueryable(); QueryToken queryToken = new QueryToken() { Value = indexPropertyToSearchOn + QueryNodeExtensions.FieldTermDelimeter + searchValue, Next = QueryToken.Empty, }; // Act QueryNode node = QueryNodeExtensions.ConvertTokensIntoNodes(queryToken); // Assert Assert.True(node.IsActionNode()); Assert.Collection(node.Apply(queryable), elementInspectors); }
public void QueryNode_ConvertTokensIntoNodes_SingleQueryToken() { // Arrange string indexPropertyToSearchOn = "term"; string searchValue = "searchValue"; IQueryable <Index> queryable = GetTestIQueryable(indexPropertyToSearchOn, searchValue); QueryToken queryToken = new QueryToken() { Value = indexPropertyToSearchOn + QueryNodeExtensions.FieldTermDelimeter + searchValue, Next = QueryToken.Empty, }; // Act QueryNode node = QueryNodeExtensions.ConvertTokensIntoNodes(queryToken); // Assert Assert.True(node.IsActionNode()); Index indexFound = Assert.Single(node.Apply(queryable)); Assert.Equal(indexPropertyToSearchOn, indexFound.Field); Assert.Equal(searchValue, indexFound.Term); }