This commit is contained in:
2018-10-09 18:47:27 +00:00
parent 2f5d2a8d26
commit d57422ef6a

View File

@@ -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<long>();
//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<long> MatchingIdList = new List<long>();
foreach (JObject j in v)
{
MatchingIdList.Add(j["id"].Value<long>());
}
//Ensure the expected items are returned
MatchingIdList.Should().Contain(MatchWidgetInSerialId, "ShouldContainMatchWidgetInSerialId");
}//eot