diff --git a/Search/SearchOps.cs b/Search/SearchOps.cs index 23da3f0..bb47041 100644 --- a/Search/SearchOps.cs +++ b/Search/SearchOps.cs @@ -287,55 +287,33 @@ namespace raven_integration dynamic TagsArray = new JArray(); TagsArray.Add(SearchTagPhrase); - //w.tags = InclusiveTagsArray; //CREATE A PROJECT - dynamic D = new JObject(); - D.name = Util.Uniquify("TAG search test PROJECT TAG AND PHRASE"); + var projectName = Util.Uniquify("TAG search test PROJECT TAG AND PHRASE"); + var dateStarted = DateTime.Now.ToString("o"); + var payload = $$""" + {"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This record will match in notes and tag: elementary my dear aardvark","wiki":null,"customFields":"{}","tags":["{{SearchTagPhrase}}","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"} + """; - D.dollarAmount = 1.11m; - D.active = true; - D.usertype = 1; - D.notes = "This record will match in notes and tag: elementary my dear aardvark"; - D.tags = TagsArray; - - ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); + ApiResponse a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload); Util.ValidateDataReturnResponseOk(a); long MatchProjectInNotesId = a.ObjectResponse["data"]["id"].Value(); - - - //CREATE A PROJECT WITH TAG BUT NOT SEARCH PHRASE - D = new JObject(); - D.name = Util.Uniquify("TAG search test PROJECT TAG ONLY"); - - D.dollarAmount = 1.11m; - D.active = true; - D.usertype = 1; - D.notes = "This record will match in tag but no search phrase"; - D.tags = TagsArray; - - a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); + projectName = Util.Uniquify("TAG search test PROJECT TAG ONLY"); + payload = $$""" + {"id":0,"concurrency":0,"name":"{{projectName}}","active":true,"notes":"This record will match in tag but no search phrase","wiki":null,"customFields":"{}","tags":["{{SearchTagPhrase}}","zebra"],"dateStarted":"{{dateStarted}}","dateCompleted":null,"projectOverseerId":null,"accountNumber":"TestAccountNumber"} + """; + a = await Util.PostAsync("project", await Util.GetTokenAsync("superuser", "l3tm3in"), payload); Util.ValidateDataReturnResponseOk(a); long NoPhraseMatchProjectInTagId = a.ObjectResponse["data"]["id"].Value(); - - - + //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.active = true; - D.login = Util.Uniquify("LOGIN"); - D.password = Util.Uniquify("PASSWORD"); - D.usertype = 1; - - D.userType = 2;// not service type user - D.customFields = Util.UserRequiredCustomFieldsJsonString(); - - a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), D.ToString()); + var userName = Util.Uniquify("Wildcard contains search NAME elementary aardvark Test User"); + payload = $$""" + {"id":0,"concurrency":0,"active":true,"allowLogin":true,"name":"{{userName}}","roles":8,"userType":2,"employeeNumber":null,"notes":"This user has the match in it's name but no tag match","customerId":null,"headOfficeId":null,"vendorId":null,"wiki":null,"customFields":"{}","tags":[],"lastLogin":null,"password":"{{userName}}","login":"{{userName}}"} + """; + a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), payload); Util.ValidateDataReturnResponseOk(a); long MatchUserInNameId = a.ObjectResponse["data"]["id"].Value(); @@ -354,7 +332,7 @@ namespace raven_integration ((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"]); + var v = (JArray)a.ObjectResponse["data"]["searchResults"]; List MatchingIdList = new List(); foreach (JObject j in v) {