This commit is contained in:
@@ -588,6 +588,63 @@ namespace raven_integration
|
||||
}//eot
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public async void CustomFieldSearchShouldWork()
|
||||
{
|
||||
|
||||
//CREATE CUSTOM FIELD DATA TO SEARCH FOR (note must use already defined template so c2 is the text one)
|
||||
dynamic dCustomField = new JObject();
|
||||
dCustomField.c1 = "2019-02-08T06:31:48.0019809Z";
|
||||
dCustomField.c2 = "pelican beak nozzle";
|
||||
dCustomField.c3 = "747";
|
||||
dCustomField.c4 = "true";
|
||||
dCustomField.c5 = "23.45";
|
||||
|
||||
//CREATE A WIDGET
|
||||
dynamic D = new JObject();
|
||||
D.name = Util.Uniquify("CUSTOMFIELD search test WIDGET");
|
||||
D.customFields = dCustomField.ToString();
|
||||
D.dollarAmount = 1.11m;
|
||||
D.active = true;
|
||||
D.roles = 0;
|
||||
D.notes = "This record will match in custom field";
|
||||
|
||||
ApiResponse a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long MatchingWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//Now see if can find this object with a phrase search
|
||||
dynamic SearchParameters = new JObject();
|
||||
|
||||
SearchParameters.phrase = "beak pelican";
|
||||
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["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(1);//might be a successive run and still have some left so account for more than one return
|
||||
|
||||
//Turn the list into an array of id's
|
||||
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
|
||||
// v.Count.Should().Be(1);
|
||||
// v[0]["id"].Value<long>().Should().Be(MatchingWidgetId);
|
||||
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(MatchingWidgetId, "ShouldContainMatchingCustomFieldWidgetId");
|
||||
|
||||
|
||||
}//eot
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
|
||||
Reference in New Issue
Block a user