예제 #1
0
        public void InvalidUpdateFieldSpecial(Enum param, MapperData.Invalid invalidValue)
        {
            string fieldUUID  = PreparedFieldId.Data[ResourceId.Client].ToString();
            string parameter  = param.GetEnumStringValue() == Properties.Parameters.Guid.GetEnumStringValue() ? fieldUUID : param.GetEnumStringValue();
            var    handler    = new DefaultManager();
            var    properties = NumberHelpers.GenerateRequiredProperties((int)FieldType.Number, Properties.Label.Min);

            if (param.GetType() == typeof(Properties.PropertyName))
            {
                CreateUpdateTestData.InvalidMapperValue[invalidValue](properties, parameter);
            }
            var updateParam = NumberHelpers.GenerateUpdateParam(ResourceId.Client, properties);

            CreateUpdateTestData.InjectInvalidValue(parameter, updateParam, invalidValue);
            var idParam = new Dictionary <string, object>
            {
                [fieldUUID] = updateParam
            };

            CreateUpdateTestData.InjectInvalidValue(parameter, idParam, invalidValue);
            var request = new Dictionary <string, object>
            {
                [Properties.Parameters.Update.GetEnumStringValue()] = idParam
            };

            CreateUpdateTestData.InjectInvalidValue(parameter, request, invalidValue);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, request.ToJson(), HttpMethod.PUT);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able update Field");
        }
        public void InvalidCreateFieldSpecial(Enum param, MapperData.Invalid invalidValue)
        {
            string parameter  = param.GetEnumStringValue();
            var    properties = NumberHelpers.GenerateRequiredProperties((int)FieldType.Number, Properties.Label.Max);

            if (param.GetType() == typeof(Properties.PropertyName))
            {
                CreateUpdateTestData.InvalidMapperValue[invalidValue](properties, parameter);
            }
            var handler     = new DefaultManager();
            var createParam = GenerateCreateParam(properties);

            CommonMapperValue.AliasMapperValue[Properties.Alias.Max](createParam);
            CreateUpdateTestData.InjectInvalidValue(parameter, createParam, invalidValue);
            var request = GenerateCreateRequest(createParam);

            CreateUpdateTestData.InjectInvalidValue(parameter, request, invalidValue);
            var response = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, request.ToJson(), HttpMethod.POST);

            if (param.GetEnumStringValue() == Properties.PropertyName.Label.GetEnumStringValue() && invalidValue == MapperData.Invalid.SpecialChars)
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Not able Create Field");
            }
            else if ((param.GetEnumStringValue() == Properties.PropertyName.Caption.GetEnumStringValue() && (invalidValue == MapperData.Invalid.StringEmpty || invalidValue == MapperData.Invalid.Missing || invalidValue == MapperData.Invalid.SpecialChars)) ||
                     (param.GetEnumStringValue().ContainsStrings(new[] { Properties.PropertyName.Caption, Properties.PropertyName.Search, Properties.PropertyName.Match, Properties.PropertyName.Web, Properties.PropertyName.Highlight, Properties.PropertyName.Require }.Select(e => e.GetEnumStringValue()).ToArray()) && (invalidValue == MapperData.Invalid.Missing)) ||
                     (param.GetEnumStringValue() == Properties.PropertyName.SType.GetEnumStringValue() && invalidValue == MapperData.Invalid.PositiveNumberWithPlusSign) ||
                     (param.GetEnumStringValue() == Properties.PropertyName.Default.GetEnumStringValue() && invalidValue == MapperData.Invalid.StringEmpty))
            {
                PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Not able Create Field");
            }
            else
            {
                PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able Create Field");
            }
        }