public void TestInvalidCreateTemplateReplaceInjection(TemplateReplaceParameters param, Enums.InvalidInjection invalid) { var handler = new DefaultManager(); var request = BuildTemplateReplaceRequest(ResourceId.Client, RecordsCreator.Data[$"{ResourceId.Client}0"].Id, Id); if (param == TemplateReplaceParameters.RecordId || param == TemplateReplaceParameters.ResourceTypeId) { var item = (request[TemplateReplaceParameters.ResourceMap.GetEnumStringValue()] as List <Dictionary <string, object> >)[0]; item[param.GetEnumStringValue()] = MapperData.InvalidInjectionMapper[invalid]; request[TemplateReplaceParameters.ResourceMap.GetEnumStringValue()] = item; } else { request[param.GetEnumStringValue()] = MapperData.InvalidInjectionMapper[invalid]; } var response = handler.Send <object>(TemplateReplaceEndPoint, JsonConvert.SerializeObject(request), HttpMethod.POST); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
private static Dictionary <string, object> GetTemplaceRepalce(TemplateReplaceParameters param, InvalidValue invalid, Dictionary <string, object> request) { if (param == TemplateReplaceParameters.RecordId || param == TemplateReplaceParameters.ResourceTypeId) { var item = (request[TemplateReplaceParameters.ResourceMap.GetEnumStringValue()] as List <Dictionary <string, object> >)[0]; if (invalid == InvalidValue.MissingParam) { item.Remove(param.GetEnumStringValue()); } else { InvalidValueMapper[invalid](item, param.GetEnumStringValue()); } request[TemplateReplaceParameters.ResourceMap.GetEnumStringValue()] = new List <Dictionary <string, object> > { item }; } else { InvalidValueMapper[invalid](request, param.GetEnumStringValue()); } return(request); }