Пример #1
0
        public void TestCreateDuplicateParameterTemplateReplace(TemplateReplaceParameters param, Enums.ValidDuplicated inputType)
        {
            var handler = new DefaultManager();
            var request = BuildTemplateReplaceRequest(ResourceId.Client, RecordsCreator.Data[$"{ResourceId.Client}0"].Id, Ids.ElementAt(1));

            DuplicateTemplateReplaceParameters[param](inputType, Ids.ElementAt(0), RecordsCreator.Data[$"{ResourceId.Activity}0"].Id, request);
            var response = handler.Send <object>(TemplateEndPoint, JsonConvert.SerializeObject(request).Replace("_Dup", string.Empty), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
        }
        public void TestInvalidTemplateReplace(TemplateReplaceParameters param, InvalidValue invalid)
        {
            var resource = ResourceId.Client;
            var handler  = new DefaultManager();
            var request  = BuildTemplateReplaceRequest(resource, RecordsCreator.Data[$"{resource}0"].Id, Id);

            request = GetTemplaceRepalce(param, invalid, request);
            var response = handler.Send <object>(TemplateReplaceEndPoint, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest));
        }
Пример #3
0
        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);
 }