예제 #1
0
        public void ValidCreateFieldOptionalProperties(ResourceId resourceId, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Default defaultProperty, Properties.Min min, Properties.Max max, Properties.Scale scale)
        {
            var handler     = new DefaultManager();
            var properties  = NumberHelpers.GenerateProperties(NumberFieldTestData.NumberFieldType, Properties.Label.Max, caption, search, match, highlight, require, defaultProperty, min, max, scale);
            var createParam = new Dictionary <string, object>
            {
                [Properties.Parameters.Resource.GetEnumStringValue()]   = resourceId.ToString().ToLower(),
                [Properties.Parameters.Alias.GetEnumStringValue()]      = "",
                [Properties.Parameters.Properties.GetEnumStringValue()] = properties
            };

            CommonMapperValue.AliasMapperValue[alias](createParam);
            var request = new Dictionary <string, object>
            {
                [Properties.Parameters.Create.GetEnumStringValue()] = createParam
            }.ToJson();

            PrAssert.That(request, PrIs.Not.EqualTo(string.Empty));
            var response = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Can not Create Field");
            var fieldHandler = new FieldManager();
            var readResponse = fieldHandler.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[Properties.Label.Max]), "Not as expected d.label.ja");
            NumberHelpers.VerifyProperties(readResponse.Result.Values.First().Value.Properties, properties);
        }
예제 #2
0
        public void TestCreateOptionalParameterValid(ResourceId resource, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require, Properties.Length length, Properties.Default deft, Properties.Height height)
        {
            var handler    = new DefaultManager();
            var properties = TextHelpers.GenerateWithRequireProperties(Defines.FieldTypeApi, caption, search, match, web, highlight, require, length, deft, height);
            var request    = TextHelpers.GenerateCreateRequest(resource, alias, properties);
            var response   = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(response.Result.Id, PrIs.Not.Null.Or.Not.Empty);

            var result = (new FieldManager()).GetFieldDetails(response.Result.Id);

            //Clearn up
            CommonHelpers.DeleteField(new List <Guid> {
                response.Result.Id
            });
            //Verify
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Id, PrIs.EqualTo(response.Result.Id));
            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, properties);
        }
예제 #3
0
        public void TestCreateOptionalParameterValid(ResourceId resource, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Web web, Properties.Highlight highlight, Properties.Require require)
        {
            var id         = UuidUtil.GetId(FieldsCreator.Data[$"{Defines.ReferenceResource[resource].First()}-{HRBCClientPrivate.API.Field.FieldType.Mail.ToString()}-0"].Guid);
            var handler    = new DefaultManager();
            var properties = TextHelpers.GenerateWithRequireProperties(Defines.FieldTypeApi, caption, search, match, web, highlight, require);

            properties[Properties.PropertyName.Field.GetEnumStringValue()] = id;
            var request  = TextHelpers.GenerateCreateRequest(resource, alias, properties);
            var response = handler.Send <FieldCreateResponse>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK));
            PrAssert.That(response.Result.Id, PrIs.Not.Null.Or.Not.Empty);

            var result = (new FieldManager()).GetFieldDetails(response.Result.Id);

            //Clearn up
            CommonHelpers.DeleteField(new List <Guid> {
                response.Result.Id
            });
            //Verify
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Id, PrIs.EqualTo(response.Result.Id));
            TextHelpers.VerifyProperties(result.Result.Values.SingleOrDefault().Value.Properties, properties);
        }
예제 #4
0
        public static void SendAndVerifyRequest(int fieldType, ResourceId resourceId, Properties.Alias alias, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Highlight highlight, Properties.Require require, Properties.Default defaultProperty, FileType mimeType, Properties.Height height, string fieldUUID)
        {
            var handler     = new DefaultManager();
            var properties  = GenerateProperties(fieldType, Properties.Label.Max, caption, search, match, highlight, require, defaultProperty, mimeType, height);
            var updateParam = GenerateUpdateParam(resourceId, properties);
            var request     = GenerateRequestUpdate(fieldUUID, updateParam).ToJson();

            PrAssert.That(request, PrIs.Not.EqualTo(string.Empty));
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, request, HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent), "Can not update Field");
            var fieldHandler = new FieldManager();
            var readResponse = fieldHandler.GetFieldDetails(new Guid(fieldUUID));

            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($"{fieldType}"), "Not as expected s.type");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[Properties.Label.Max]), "Not as expected d.label.ja");
            VerifyProperties(readResponse.Result.Values.First().Value.Properties, properties);
        }
예제 #5
0
        public static Dictionary <string, object> GenerateCreateRequest(ResourceId resource, Properties.Alias alias, Dictionary <string, object> properties)
        {
            var create  = Properties.Parameters.Create.GetEnumStringValue();
            var request = new Dictionary <string, object>
            {
                [create] = new Dictionary <string, object>
                {
                    [Properties.Parameters.Resource.GetEnumStringValue()]   = resource.ToString(),
                    [Properties.Parameters.Properties.GetEnumStringValue()] = properties
                }
            };

            CommonMapperValue.AliasMapperValue[alias](request[create] as Dictionary <string, object>);
            return(request);
        }