public void TestCreateRequireParameterValid(ResourceId resource, Properties.Label label, TextHelpers.FieldTypes fType, ResourceId refResource)
        {
            var guid     = TextHelpers.Guid[fType](refResource, FieldsCreator, HRBCClientPrivate.API.Field.FieldType.Mail, TextHelpers.ApplicationFieldNames[HRBCClientPrivate.API.Field.FieldType.Mail]().First());
            var id       = UuidUtil.GetId(guid);
            var handler  = new FieldManager();
            var response = handler.CreateField(resource, new Dictionary <string, object>
            {
                [Properties.PropertyName.SType.GetEnumStringValue()] = Defines.FieldTypeApi,
                [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label],
                [Properties.PropertyName.Field.GetEnumStringValue()] = id
            });

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

            var result = handler.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));
            PrAssert.That(result.Result.Values.First().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo(((int)Defines.FieldTypeApi).ToString()), "Not as expected s.type");
            PrAssert.That(result.Result.Values.First().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]), "Not as expected d.label.ja");
            PrAssert.That(result.Result.Values.First().Value.Properties[Properties.PropertyName.Field.GetEnumStringValue()], PrIs.EqualTo(id.ToString()), "Not as expected s.l.field");
        }
Beispiel #2
0
        public static Dictionary <string, object> GenerateProperties(int fieldType, Properties.Label label, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Highlight highlight, Properties.Require require, Properties.Default defaultProperty, FileType mimeType, Properties.Height height)
        {
            var properties = GenerateRequiredProperties(fieldType, label, mimeType);

            CommonMapperValue.CaptionMapperValue[caption](properties);
            CommonMapperValue.SearchMapperValue[search](properties);
            CommonMapperValue.MatchMapperValue[match](properties);
            CommonMapperValue.HighlightMapperValue[highlight](properties);
            CommonMapperValue.RequireMapperValue[require](properties);
            DefaultMapperValue[defaultProperty](properties);
            HeightMapperValue[height](properties);
            return(properties);
        }
Beispiel #3
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");
        }
Beispiel #4
0
        public static Dictionary <string, object> GenerateProperties(int fieldType, Properties.Label label, Properties.Caption caption, Properties.Search search, Properties.Match match, Properties.Highlight highlight, Properties.Require require, Properties.Default defaultProperty, Properties.Min min, Properties.Max max, Properties.Scale scale)
        {
            var properties = GenerateRequiredProperties(fieldType, label);

            CommonMapperValue.CaptionMapperValue[caption](properties);
            CommonMapperValue.SearchMapperValue[search](properties);
            CommonMapperValue.MatchMapperValue[match](properties);
            CommonMapperValue.HighlightMapperValue[highlight](properties);
            CommonMapperValue.RequireMapperValue[require](properties);
            NumberHelpers.DefaultMapperValue[defaultProperty](scale, properties);
            NumberHelpers.MinMapperValue[min](properties);
            NumberHelpers.MaxMapperValue[max](properties);
            NumberHelpers.ScaleMapperValue[scale](properties);
            return(properties);
        }
        public void ValidCreateFieldRequiredProperties(ResourceId resourceId, Properties.Label label, FileType mimeType)
        {
            var handler    = new FieldManager();
            var properties = FileHelpers.GenerateRequiredProperties(FileFieldTestData.FileFieldType, label, mimeType);

            FileHelpers.HeightMapperValue[Properties.Height.Max](properties);
            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($"{FileFieldTestData.FileFieldType}"), "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");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.VType.GetEnumStringValue()], PrIs.EqualTo(CommonConstants.Files[mimeType].MimeType), "Not as expected v.f.type");
            PrAssert.That(readResponse.Result.Values.First().Value.Properties[Properties.PropertyName.DType.GetEnumStringValue()], PrIs.EqualTo($"{FileFieldTestData.DisplayType}"), "Not as expected d.type");
        }
        public void TestCreateRequireParameterValid(ResourceId resource, Properties.Label label)
        {
            var handler  = new FieldManager();
            var response = handler.CreateField(resource, new Dictionary <string, object>
            {
                [CommonHelpers.GetEnumStringValue(Properties.PropertyName.SType)] = Defines.FieldTypeApi,
                [CommonHelpers.GetEnumStringValue(Properties.PropertyName.Label)] = CommonMapperValue.LabelMapperValue[label]
            });

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

            var result = handler.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));
            PrAssert.That(result.Result.Values.First().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo(((int)Defines.FieldTypeApi).ToString()), "Not as expected s.type");
            PrAssert.That(result.Result.Values.First().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]), "Not as expected d.label.ja");
        }
        public void ValidUpdateApplicationFieldRequiredProperties(ResourceId resourceId, Properties.Label label)
        {
            string fieldUUID = ApplicationFieldId.Data[resourceId].ToString();

            NumberHelpers.SendAndVerifyRequiredProperties(NumberFieldTestData.NumberFieldType, resourceId, label, fieldUUID);
        }
Beispiel #8
0
        public static void SendAndVerifyRequiredProperties(int fieldType, ResourceId resourceId, Properties.Label label, FileType mimeType, string fieldUUID)
        {
            var handler     = new DefaultManager();
            var properties  = GenerateRequiredProperties(fieldType, label, mimeType);
            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[label]), "Not as expected d.label.ja");
        }
Beispiel #9
0
 public static Dictionary <string, object> GenerateRequiredProperties(int fieldType, Properties.Label label, FileType mimeType)
 {
     return(new Dictionary <string, object>
     {
         [Properties.PropertyName.SType.GetEnumStringValue()] = fieldType,
         [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label],
         [Properties.PropertyName.DType.GetEnumStringValue()] = (int)Properties.DType.Five,
         [Properties.PropertyName.VType.GetEnumStringValue()] = CommonConstants.Files[mimeType].MimeType,
     });
 }
Beispiel #10
0
        public void TestUpdateRequireParameterValid(ResourceId resource, TextHelpers.FieldTypes fType, Properties.Label label)
        {
            var guid    = TextHelpers.Guid[fType](resource, FieldsCreator, Defines.FieldTypeApi, TextHelpers.ApplicationFieldNames[Defines.FieldTypeApi]().First());
            var handler = new DefaultManager();
            var props   = new Dictionary <string, object>
            {
                [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label]
            };

            var request  = TextHelpers.GenerateUpdateRequest(resource, guid.ToString(), props);
            var response = handler.Send <object>(FieldManager.FieldHandlingRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.NoContent));

            //Verify
            var result = (new FieldManager()).GetFieldDetails(guid);

            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]));
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[Properties.PropertyName.SType.GetEnumStringValue()], PrIs.EqualTo(((int)Defines.FieldTypeApi).ToString()), "Not as expected s.type");
            PrAssert.That(result.Result.Values.SingleOrDefault().Value.Properties[Properties.PropertyName.Label.GetEnumStringValue()], PrIs.EqualTo(CommonMapperValue.LabelMapperValue[label]), "Not as expected d.label.ja");
        }
        public void ValidUpdateUserFieldRequiredProperties(ResourceId resourceId, Properties.Label label)
        {
            string fieldUUID = PreparedFieldId.Data[resourceId].ToString();

            NumberHelpers.SendAndVerifyRequiredProperties(CurrencyFieldTestData.CurrencyFieldType, resourceId, label, fieldUUID);
        }
Beispiel #12
0
        public static Dictionary <string, object> GenerateRequiredProperties(FieldType fieldType, Properties.Label label)
        {
            var result = new Dictionary <string, object>
            {
                [Properties.PropertyName.SType.GetEnumStringValue()] = (int)fieldType,
                [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label],
            };

            if (fieldType == FieldType.File)
            {
                result.Add(Properties.PropertyName.DType.GetEnumStringValue(), (int)Properties.DType.Five);
                result.Add(Properties.PropertyName.Height.GetEnumStringValue(), 50);
                result.Add(Properties.PropertyName.VType.GetEnumStringValue(), CommonConstants.Files[FileType.Bmp].MimeType);
            }
            if (fieldType == FieldType.Option)
            {
                var optionInfos = SelectionHelper.GetOptionInfos(SelectionHelper.GetOptionsAlias()[new Random().Next(SelectionHelper.GetOptionsAlias().Count)]);
                result.Add(Properties.PropertyName.Id.GetEnumStringValue(), optionInfos.FirstOrDefault().Key);
                result.Add(Properties.PropertyName.DType.GetEnumStringValue(), (int)SelectionHelper.DTypeMapper[fieldType]);
                result.Add(Properties.PropertyName.Count.GetEnumStringValue(), (int)Properties.OptionCount.Zero);
            }
            return(result);
        }
        public void ValidUpdateApplicationFieldRequiredProperties(ResourceId resourceId, Properties.Label label, FileType mimeType)
        {
            string fieldUUID = ApplicationFieldId.Data[resourceId].ToString();

            FileHelpers.SendAndVerifyRequiredProperties(FileFieldTestData.FileFieldType, resourceId, label, mimeType, fieldUUID);
        }
Beispiel #14
0
 public static Dictionary <string, object> GenerateRequiredProperties(int fieldType, Properties.Label label)
 {
     return(new Dictionary <string, object>
     {
         [Properties.PropertyName.SType.GetEnumStringValue()] = fieldType,
         [Properties.PropertyName.Label.GetEnumStringValue()] = CommonMapperValue.LabelMapperValue[label]
     });
 }