This commit is contained in:
2018-12-06 20:26:57 +00:00
parent 5641670961
commit fc1902bfe5

View File

@@ -348,100 +348,100 @@ namespace raven_integration
}//eot
[Fact]
public async void TagSearchShouldWork()
{
const string TEST_SEARCH_PHRASE = "element* aardvark";
// [Fact]
// public async void TagSearchShouldWork()
// {
// const string TEST_SEARCH_PHRASE = "element* aardvark";
//CREATE A WIDGET
dynamic D = new JObject();
D.name = Util.Uniquify("TAG search test WIDGET TAG AND PHRASE");
D.dollarAmount = 1.11m;
D.active = true;
D.roles = 0;
D.notes = "This record will match in notes and tag: elementary my dear aardvark";
// //CREATE A WIDGET
// dynamic D = new JObject();
// D.name = Util.Uniquify("TAG search test WIDGET TAG AND PHRASE");
// D.dollarAmount = 1.11m;
// D.active = true;
// D.roles = 0;
// D.notes = "This record will match in notes and tag: elementary my dear aardvark";
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
// a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
// Util.ValidateDataReturnResponseOk(a);
// long MatchWidgetInNotesId = a.ObjectResponse["data"]["id"].Value<long>();
//TAG the widget with the fresh tag
D = new JObject();
D.tagId = TagId;
D.tagToObjectId = MatchWidgetInNotesId;
D.tagToObjectType = 2;//widget
a = await Util.PostAsync("TagMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
// //TAG the widget with the fresh tag
// D = new JObject();
// D.tagId = TagId;
// D.tagToObjectId = MatchWidgetInNotesId;
// D.tagToObjectType = 2;//widget
// a = await Util.PostAsync("TagMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
// Util.ValidateDataReturnResponseOk(a);
//CREATE A WIDGET WITH TAG BUT NOT SEARCH PHRASE
D = new JObject();
D.name = Util.Uniquify("TAG search test WIDGET TAG ONLY");
D.dollarAmount = 1.11m;
D.active = true;
D.roles = 0;
D.notes = "This record will match in tag but no search phrase";
// //CREATE A WIDGET WITH TAG BUT NOT SEARCH PHRASE
// D = new JObject();
// D.name = Util.Uniquify("TAG search test WIDGET TAG ONLY");
// D.dollarAmount = 1.11m;
// D.active = true;
// D.roles = 0;
// D.notes = "This record will match in tag but no search phrase";
a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
long NoPhraseMatchWidgetInTagId = a.ObjectResponse["data"]["id"].Value<long>();
// a = await Util.PostAsync("Widget", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
// Util.ValidateDataReturnResponseOk(a);
// long NoPhraseMatchWidgetInTagId = a.ObjectResponse["data"]["id"].Value<long>();
//TAG the tag only no phrase with the fresh tag
D = new JObject();
D.tagId = TagId;
D.tagToObjectId = NoPhraseMatchWidgetInTagId;
D.tagToObjectType = 2;//widget
// //TAG the tag only no phrase with the fresh tag
// D = new JObject();
// D.tagId = TagId;
// D.tagToObjectId = NoPhraseMatchWidgetInTagId;
// D.tagToObjectType = 2;//widget
a = await Util.PostAsync("TagMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
Util.ValidateDataReturnResponseOk(a);
// a = await Util.PostAsync("TagMap", await Util.GetTokenAsync("BizAdminFull"), D.ToString());
// Util.ValidateDataReturnResponseOk(a);
//CREATE FIRST TEST USER WITH PHRASE IN NAME BUT NO TAG
D = new JObject();
D.name = Util.Uniquify("Wildcard contains search NAME elementary aardvark Test User");
D.notes = "This user has the match in it's name but no tag match";
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
// //CREATE FIRST TEST USER WITH PHRASE IN NAME BUT NO TAG
// D = new JObject();
// D.name = Util.Uniquify("Wildcard contains search NAME elementary aardvark Test User");
// D.notes = "This user has the match in it's name but no tag match";
// 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["data"]["id"].Value<long>();
// a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), D.ToString());
// Util.ValidateDataReturnResponseOk(a);
// long MatchUserInNameId = a.ObjectResponse["data"]["id"].Value<long>();
//Now see if can find those objects with a phrase search
dynamic SearchParameters = new JObject();
// //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
//product.Tags = new JArray("Real", "OnSale");
SearchParameters.tags = new JArray(new long[] { TagId });
a = await Util.PostAsync("Search", await Util.GetTokenAsync("manager", "l3tm3in"), SearchParameters.ToString());
Util.ValidateDataReturnResponseOk(a);
// SearchParameters.phrase = TEST_SEARCH_PHRASE;
// SearchParameters.nameOnly = false;
// SearchParameters.typeOnly = 0;//no type
// //product.Tags = new JArray("Real", "OnSale");
// SearchParameters.tags = new JArray(new long[] { TagId });
// 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);
// //Now validate the return list
// ((JArray)a.ObjectResponse["data"]["searchResults"]).Count.Should().BeGreaterOrEqualTo(1);
//Turn the list into an array of id's
var v = ((JArray)a.ObjectResponse["data"]["searchResults"]);
List<long> MatchingIdList = new List<long>();
foreach (JObject j in v)
{
MatchingIdList.Add(j["id"].Value<long>());
}
// //Turn the list into an array of id's
// var v = ((JArray)a.ObjectResponse["data"]["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(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId");
MatchingIdList.Should().NotContain(MatchUserInNameId, "ShouldNotContainMatchUserInNameId");
MatchingIdList.Should().NotContain(NoPhraseMatchWidgetInTagId, "ShouldNotContainNoPhraseMatchWidgetInTagId");
// //Ensure the expected items are returned
// MatchingIdList.Should().Contain(MatchWidgetInNotesId, "ShouldContainMatchWidgetInNotesId");
// MatchingIdList.Should().NotContain(MatchUserInNameId, "ShouldNotContainMatchUserInNameId");
// MatchingIdList.Should().NotContain(NoPhraseMatchWidgetInTagId, "ShouldNotContainNoPhraseMatchWidgetInTagId");
}//eot
// }//eot