Ejemplo n.º 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");
        }
Ejemplo n.º 2
0
        public void InvalidInjectionCreateFieldSpecial(Enum param, Enums.InvalidInjection invalidInjection)
        {
            string parameter  = param.GetEnumStringValue();
            var    properties = NumberHelpers.GenerateRequiredProperties((int)FieldType.Number, Properties.Label.Max);

            if (param.GetType() == typeof(Properties.PropertyName))
            {
                properties[parameter] = MapperData.InvalidInjectionMapper[invalidInjection];
            }
            var handler     = new DefaultManager();
            var createParam = GenerateCreateParam(properties);

            createParam.Remove(Properties.Parameters.Alias.GetEnumStringValue());
            if (param.GetEnumStringValue() != Properties.Parameters.Create.GetEnumStringValue() && param.GetType() == typeof(Properties.Parameters))
            {
                createParam[parameter] = MapperData.InvalidInjectionMapper[invalidInjection];
            }
            var request = GenerateCreateRequest(createParam);

            if (param.GetEnumStringValue() == Properties.Parameters.Create.GetEnumStringValue())
            {
                request[parameter] = MapperData.InvalidInjectionMapper[invalidInjection];
            }
            var response = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, request.ToJson(), HttpMethod.POST);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able Create Field");
        }
Ejemplo n.º 3
0
        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");
            }
        }
Ejemplo n.º 4
0
        public void InvalidCreateFieldSpecial(ResourceId resource, NumberHelpers.InvalidCreateField invalidCreateField)
        {
            var handler    = new FieldManager();
            var properties = NumberHelpers.GenerateRequiredProperties(NumberFieldTestData.NumberFieldType, Properties.Label.Max);

            NumberHelpers.InvalidCreateMapperValue[invalidCreateField](properties);
            var response = handler.CreateField(resource, properties);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able Create Field");
        }
Ejemplo n.º 5
0
        public void InvalidSpecialCreateFieldSpecial(ResourceId resourceId)
        {
            var properties  = NumberHelpers.GenerateRequiredProperties((int)FieldType.Number, Properties.Label.Max);
            var handler     = new DefaultManager();
            var createParam = GenerateCreateParam(properties);
            var request     = GenerateCreateRequest(createParam);
            var response    = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, request.ToJson(), HttpMethod.POST);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest), "Still able Create Field");
        }
Ejemplo n.º 6
0
        public void ValidCreateFieldRequiredProperties(ResourceId resourceId, Properties.Label label)
        {
            var handler    = new FieldManager();
            var properties = NumberHelpers.GenerateRequiredProperties(NumberFieldTestData.NumberFieldType, label);
            var response   = handler.CreateField(resourceId, properties);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not Create Field");
            var readResponse = handler.GetFieldDetails(response.Result.Id);

            CommonHelpers.DeleteField(new[] { response.Result.Id });
            PrAssert.That(readResponse, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not Read Field");
            PrAssert.That(readResponse.Result.Values.Count, PrIs.EqualTo(1), "Can not read Field");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo($"{NumberFieldTestData.NumberFieldType}"), "Not as expected s.type");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]), "Not as expected d.label.ja");
        }