diff --git a/test/raven-integration/Search/SearchOps.cs b/test/raven-integration/Search/SearchOps.cs index 7c1e4090..4b2fb384 100644 --- a/test/raven-integration/Search/SearchOps.cs +++ b/test/raven-integration/Search/SearchOps.cs @@ -526,6 +526,53 @@ namespace raven_integration TimeToSearch.Should().BeLessThan(57623, "Unconstrained big data search should not be too slow"); + }//eot + + + + [Fact] + public async void SearchForSerialFieldShouldWork() + { + //CREATE A WIDGET + dynamic D = new JObject(); + D.name = Util.Uniquify("Serial search test WIDGET"); + D.dollarAmount = 1.11m; + D.active = true; + D.roles = 0; + D.notes = "Test for serial number search"; + + ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); + Util.ValidateDataReturnResponseOk(a); + long MatchWidgetInSerialId = a.ObjectResponse["result"]["id"].Value(); + + //TODO: get this from the return object + string SerialSearch="99999999"; + + + //Now see if can find those objects with a phrase search + dynamic SearchParameters = new JObject(); + SearchParameters.phrase = SerialSearch; + SearchParameters.nameOnly = false; + SearchParameters.typeOnly = 0;//no type + SearchParameters.maxResults = 0; + a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString()); + Util.ValidateDataReturnResponseOk(a); + + //Now validate the return list + ((JArray)a.ObjectResponse["result"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(1); + + //Turn the list into an array of id's + var v = ((JArray)a.ObjectResponse["result"]["searchResults"]); + List MatchingIdList = new List(); + foreach (JObject j in v) + { + MatchingIdList.Add(j["id"].Value()); + } + + //Ensure the expected items are returned + MatchingIdList.Should().Contain(MatchWidgetInSerialId, "ShouldContainMatchWidgetInSerialId"); + + }//eot