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