diff --git a/test/raven-integration/Search/SearchOps.cs b/test/raven-integration/Search/SearchOps.cs index f365c486..32b93b06 100644 --- a/test/raven-integration/Search/SearchOps.cs +++ b/test/raven-integration/Search/SearchOps.cs @@ -284,6 +284,68 @@ namespace raven_integration + + [Fact] + public async void WildCardContainsSearchShouldWork() + { + const string TEST_SEARCH_PHRASE = "*cast* goose"; + + //CREATE A WIDGET + dynamic D = new JObject(); + D.name = Util.Uniquify("Wildcard contains search test WIDGET"); + D.dollarAmount = 1.11m; + D.active = true; + D.roles = 0; + D.notes = "This record will match in notes: broadcasting to the goose"; + + ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); + Util.ValidateDataReturnResponseOk(a); + long MatchWidgetInNotesId = a.ObjectResponse["result"]["id"].Value(); + + //CREATE FIRST TEST USER WITH PHRASE IN NAME + D = new JObject(); + D.name = Util.Uniquify("Wildcard contains search NAME goose elcastro Test User"); + D.notes = "This user has the match in it's name"; + D.ownerId = 1L; + D.active = true; + D.login = Util.Uniquify("LOGIN"); + D.password = Util.Uniquify("PASSWORD"); + D.roles = 0;//norole + D.localeId = 1;//random locale + D.userType = 3;//non scheduleable + + a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString()); + Util.ValidateDataReturnResponseOk(a); + long MatchUserInNameId = a.ObjectResponse["result"]["id"].Value(); + + + //Now see if can find those objects with a phrase search + dynamic SearchParameters = new JObject(); + + SearchParameters.phrase = TEST_SEARCH_PHRASE; + SearchParameters.nameOnly = false; + SearchParameters.typeOnly = 0;//no type + a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString()); + Util.ValidateDataReturnResponseOk(a); + + //Now validate the return list + ((JArray)a.ObjectResponse["result"]).Count.Should().BeGreaterOrEqualTo(2); + + //Turn the list into an array of id's + var v = ((JArray)a.ObjectResponse["result"]); + List MatchingIdList = new List(); + foreach (JObject j in v) + { + MatchingIdList.Add(j["id"].Value()); + } + + //Ensure the expected items are returned + MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId"); + MatchingIdList.Should().Contain(MatchUserInNameId, "ShouldContainMatchUserInNameId"); + + }//eot + + //TODO: TAG SEARCH ALONE TEST //TODO: TAG PLUS SEARCH PHRASE TEST