public void WhenTheUserUpdateTheRecordWithNameDescriptionAndNonServingdata(string name, string desc, int nonSer) { // get the request var request = ScenarioContext.Current.Get <RestRequest>("Request"); //add body to request var entity = new MenuCycleEntity <Dictionary <string, object> >(); [email protected]("MenuCycle"); entity.rel.Add("/rels/MenuCycle"); Dictionary <string, object> props = new Dictionary <string, object>() { { "menuCycleId", menuCycleLastId._menuCycleId }, { "name", name + DateTime.Now }, { "description", desc }, { "nonServingDays", nonSer } }; entity.properties = props; entity.entities = new List <EmbeddedProperty> { new EmbeddedProperty { Class = new List <string> { "Group" }, rel = new List <string> { "/rels/Group" }, Properties = new MenuCycleApiTests_ci.Domain.Model.Properties2 { groupId = 95 } } }; //using CamelCasePropertyNames var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var obj = JsonConvert.SerializeObject(entity, Formatting.None, settings); request.AddParameter("application/vnd.siren+json", obj, ParameterType.RequestBody); // get the client var restClient = ScenarioContext.Current.Get <RestClient>("RestClient"); //execute request and add response to context for later processing ScenarioContext.Current.AddNewRemoveExisting("Response", restClient.Execute(request)); }
public void WhenTheGroupsAndRequestSentToServer(string group, int groupOneId, int groupTwoId) { // get the request var request = ScenarioContext.Current.Get <RestRequest>("Request"); //add body to request var entity = new MenuCycleEntity <Dictionary <string, object> >(); [email protected]("MenuCycle"); entity.rel.Add("/rels/MenuCycle"); Dictionary <string, object> props = new Dictionary <string, object>() { { "menuCycleId", 0 }, { "name", "Test verify" }, { "description", "Test description" }, { "parentId", 0 }, { "isPublished", "false" }, { "isMaster", "false" }, { "nonServingDays", 0 } }; entity.properties = props; if (group == "single") { entity.entities = new List <EmbeddedProperty> { new EmbeddedProperty { Class = new List <string> { "Group" }, rel = new List <string> { "/rels/Group" }, Properties = new MenuCycleApiTests_ci.Domain.Model.Properties2 { groupId = groupOneId } } }; } else if (group == "multiple") { entity.entities = new List <EmbeddedProperty> { new EmbeddedProperty { Class = new List <string> { "Group" }, rel = new List <string> { "/rels/Group" }, Properties = new MenuCycleApiTests_ci.Domain.Model.Properties2 { groupId = groupTwoId } }, new EmbeddedProperty { Class = new List <string> { "Group" }, rel = new List <string> { "/rels/Group" }, Properties = new MenuCycleApiTests_ci.Domain.Model.Properties2 { groupId = groupOneId } } }; } else if (group == "not associated") { entity.entities = new List <EmbeddedProperty> { new EmbeddedProperty { Class = new List <string> { "Group" }, rel = new List <string> { "/rels/Group" }, Properties = new MenuCycleApiTests_ci.Domain.Model.Properties2 { groupId = groupOneId } } }; } //changing PropertyNames into CamelCase var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var obj = JsonConvert.SerializeObject(entity, Formatting.None, settings); request.AddParameter("application/vnd.siren+json", obj, ParameterType.RequestBody); // get the client var restClient = ScenarioContext.Current.Get <RestClient>("RestClient"); //execute request and add response to context for later processing ScenarioContext.Current.AddNewRemoveExisting("Response", restClient.Execute(request)); }