public async Task ServerTest()
        {
            var req = FieldRequest.CreateFields();

            req = req.Append(CreateFieldRequest.Builder().With(ResourceId.Activity, FieldType.Number, "test").Build().Content);

            var built = ((CreateFieldsRequest.IBuilderWithRecord)req).Build();

            IPrivateClient client = PrivateClient.CreateClient(new PrivateServerSettings {
                ServerUrl = new Uri("http://namtest3-web.dynamic.ps.porters.local"), LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory
            });

            using (var session = client.CreateSession(PrivateAuthentication.WithCredentials("TestCompany", "*****@*****.**", "password")))
            {
                var fields = await session.CallAsync(built);

                Assume.That(fields.FieldFailed, Has.Count.EqualTo(0));
                Assume.That(fields.FieldSuccess, Has.Count.GreaterThan(0));
                var mapping = fields.FieldSuccess.ToDictionary(entry => entry.Value, entry => entry.Key);

                var res = await session.CallAsync(FieldRequest.GetFields().Select(FieldProperty.Name).WhereGuid(fields.FieldSuccess.Values));

                var conv = res
                           .ToDictionary(fieldEntry => mapping[(Guid)fieldEntry.Value[FieldProperty.Id]], fieldEntry => fieldEntry.Value);
                Assert.That(res, Has.Count.GreaterThan(0));
            }
        }
        private void InitFieldCreator()
        {
            var    fieldRequestBuilder = FieldRequest.CreateFields();
            string mimeType            = "image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp";

            foreach (var resourceId in Enum.GetValues(typeof(Enums.ResourceType)).Cast <Enums.ResourceType>())
            {
                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Required(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Required}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Required(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoRequired}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Searchable(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Searchable}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Searchable(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{UnSearchable}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Web(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Web}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Web(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoWeb}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Highlight(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Document}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Highlight(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoDocument}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Copy(true).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Copy}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Copy(false).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoCopy}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field", "TEST")
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Annotation}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field", null)
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoAnnotation}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Height(100).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{Height}");

                fieldRequestBuilder.Append(CreateFieldRequest.Builder().With((ResourceId)(int)resourceId, HRBCClientPrivate.API.Field.FieldType.File, "API automation test field")
                                           .MimeType(mimeType).Height(HeightDefault).DisplayType(DisplayType.SearchBoxMultiSelection).Build().Content, $"{resourceId}-{NoHeight}");
            }

            var fieldRequest = ((CreateFieldsRequest.IBuilderWithRecord)fieldRequestBuilder).Build().Content;

            customFields = new HrbcFieldCreator(fieldRequest, new List <FieldProperty> {
                FieldProperty.Id, FieldProperty.Name, FieldProperty.Resource
            });
        }
Exemplo n.º 3
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((ResourceId)resource, (HRBCClientPrivate.API.Field.FieldType)((int)(HRBCClientPrivate.API.Field.FieldType.SingleLineText)), $"{resource}_TestField").Build().Content, $"{resource}");
            }
            UserField = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name, FieldProperty.Resource });
        }
Exemplo n.º 4
0
        public static HrbcFieldCreator PrepareAttachmentField()
        {
            var request = FieldRequest.CreateFields();

            request.Append(CreateFieldRequest.Builder().With(ResourceId.Client, FieldType.File, $"{ResourceId.Client}_{FieldType.File}")
                           .DisplayType(DisplayType.SearchBoxMultiSelection)
                           .Height(50)
                           .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{ResourceId.Client}_{FieldType.File}");
            return(new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType }));
        }
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((ResourceId)resource, (FieldType)((int)(TestCoreFramework.Enums.FieldType.SingleLineText)), "Test Field").Build().Content, $"{resource.ToString()}");
            }
            FieldCreator      = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name });
            FieldCreatorOther = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Name });
        }
Exemplo n.º 6
0
        public ValidReportDataReadTests()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Utils.Resources())
            {
                request.Append(CreateFieldRequest.Builder().With((HRBCClientPrivate.Common.ResourceId)resource, (HRBCClientPrivate.API.Field.FieldType)((int)(TestCoreFramework.Enums.FieldType.SingleLineText)), "Test Field").Build().Content, $"{resource.ToString()}");
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
Exemplo n.º 7
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                var fieldType = TestCoreFramework.Enums.FieldType.DateTime;
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
Exemplo n.º 8
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                foreach (var fieldType in SearchConstants.RequiredFieldTypes.Except(new[] { TestCoreFramework.Enums.FieldType.OptionCheckbox }))
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
                request.Append(CreateFieldRequest.Builder().With(resource, HRBCClientPrivate.API.Field.FieldType.OptionCheckbox, $"{resource}_OptionCheckbox")
                               .OptionCount(0).OptionMaster("Option.P_ContructorType").DisplayType(DisplayType.CheckBox).Build().Content, $"{resource}_OptionCheckbox");
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id });
        }
Exemplo n.º 9
0
        protected string CreateNewField(ISession <PrivateAuthentication> session, Enums.ResourceType type, string label = null)
        {
            if (null == label)
            {
                label = "My test field";
            }
            var request = CreateFieldRequest.Builder()
                          .With(type.ToString().ToResourceId(), FieldType.Date, label)
                          //.JapaneseLabel(label)
                          //.JapaneseCaption("Date field")
                          .DefaultValue("2016/09/24")
                          .Required(false)
                          .Searchable(true)
                          .Web(false)
                          .Highlight(false);
            var id = session.Call(request.Build());

            return(id.ToString());
        }
Exemplo n.º 10
0
        public static CreateFieldsRequest PrepareReferenceFields(Func <ResourceId, Dictionary <string, ulong> > targetFieldsProvider)
        {
            var request = FieldRequest.CreateFields();

            foreach (var masterResource in CommonConstants.ResourceToPossibleReferenceResourcesMap)
            {
                foreach (var dependentResource in masterResource.Value)
                {
                    foreach (var targetField in targetFieldsProvider(dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentResource}.{targetField.Key}")
                                       .Searchable(true)
                                       .Name($"{(int)dependentResource}{targetField.Key.Replace("_","")}")
                                       .LinkedField(targetField.Value.ToString()).Build().Content, new ReferenceInfo(masterResource.Key, dependentResource, targetField.Key, targetField.Value));
                    }
                }
            }
            return(((CreateFieldsRequest.IBuilderWithRecord)request).Build().Content);
        }
Exemplo n.º 11
0
        public void TestCreateFieldWithBuilderAsync()
        {
            var request = CreateFieldRequest.Builder()
                          .Resource(ResourceId.Job)
                          .Required(false)
                          .FieldType(FieldType.Date)
                          .DefaultValue(DateTime.Now.ToString("yyyy/MM/dd"))
                          .Searchable(false)
                          .JapaneseLabel("This a date field")
                          .JapaneseCaption("This is a date field");
            Task <IdModel> result = session.CallAsync(request.GetRequest());

            TestContext.Out.WriteLine("Take a cup of coffee in meantime!");
            IdModel response = result.Result;

            TestContext.Out.WriteLine("Start to get the result !");
            Assert.That(response, Is.Not.Null, "Response data is null!");
            Assert.That(string.IsNullOrEmpty(response.Id), Is.False, "Id is null!");
            TestContext.Out.WriteLine(string.Format("Id: {0}", response.Id));
            fieldIdList.Add(response.Id);
        }
Exemplo n.º 12
0
        public async Task SimpleInputCreatesField()
        {
            Guid expectedId = HRBCClientPrivate.Util.UuidUtil.BuildFieldGuid(101, 303, ResourceId.Client);

            var expectedResponse = "{'id':'" + expectedId.ToString() + "'}";
            var expectedRequest  = @"{""create"":{""dataType"":""number"",""resource"":""client"",""properties"":{""s.type"":3,""d.label.ja"":""test"",""d.caption.ja"":""""}}}";
            var mocker           = HrbcVersion.Trunk.ToRequestMocker();

            mocker.WhenRequest(HttpRequestConstraint.HttpRequest()
                               .WithMethod(HttpMethod.Post)
                               .WithUri("field/field")
                               .WithContent(expectedRequest))
            .RespondWith(expectedResponse);

            using (var session = mocker.Session)
            {
                var id = await session.CallAsync(CreateFieldRequest.Builder().With(ResourceId.Client, FieldType.Number, "test"));

                Assert.That(id, Is.EqualTo(expectedId));
            }
        }
Exemplo n.º 13
0
        private void PrepareFields()
        {
            var request = FieldRequest.CreateFields();

            var fieldList = new List <HrbcFieldCreator.FieldSpec>();

            foreach (var resource in Enum.GetValues(typeof(ResourceId)).Cast <ResourceId>().Except(new[] { ResourceId.None }))
            {
                foreach (var fieldType in FieldTypeToTest.Except(new[] { TestCoreFramework.Enums.FieldType.File }))
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, (HRBCClientPrivate.API.Field.FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}");
                }
                foreach (var imageType in ImageFileTypes)
                {
                    request.Append(CreateFieldRequest.Builder().With(resource, HRBCClientPrivate.API.Field.FieldType.File, $"{resource}_File_{imageType}")
                                   .DisplayType(DisplayType.SearchBoxMultiSelection)
                                   .Height(50)
                                   .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{resource}_File_{imageType}");
                }
            }
            FieldCreator = new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType });
        }
Exemplo n.º 14
0
        public static HrbcFieldCreator PrepareFields(int num)
        {
            var   request      = FieldRequest.CreateFields();
            ulong OptionMaster = 29;

            foreach (var resource in Resources)
            {
                for (var i = 0; i < num; i++)
                {
                    foreach (var fieldType in FieldTypeToTest.Except(new[] { FieldType.File, FieldType.Option }))
                    {
                        request.Append(CreateFieldRequest.Builder().With(resource, (FieldType)((int)(fieldType)), $"{resource}_{fieldType}").Build().Content, $"{resource}_{fieldType}_{i}");
                    }
                    request.Append(CreateFieldRequest.Builder().With(resource, FieldType.File, $"{resource}_{FieldType.File}")
                                   .DisplayType(DisplayType.SearchBoxMultiSelection)
                                   .Height(50)
                                   .MimeType("image/gif,image/jpeg,image/png,image/bmp,image/x-ms-bmp").Build().Content, $"{resource}_{FieldType.File}_{i}");
                    request.Append(resource, FieldType.Option, $"{FieldType.Option}",
                                   content => content.Searchable(true).Copy(false).Required(false).OptionCount(0).DisplayType(DisplayType.CheckBox).OptionMaster(OptionMaster), $"{resource}_{FieldType.Option}_{i}");
                }
            }
            return(new HrbcFieldCreator((CreateFieldsRequest.IBuilderWithRecord)request, new[] { FieldProperty.Id, FieldProperty.Resource, FieldProperty.Name, FieldProperty.FieldType }));
        }
        private CreateFieldsRequest PrepareReferenceFields()
        {
            var request = FieldRequest.CreateFields();

            foreach (var masterResource in ResourceToPossibleReferenceResourcesMap)
            {
                foreach (var dependentResource in masterResource.Value)
                {
                    foreach (var dependentField in FieldReader.Data.Where(pair => pair.Key.Resource == dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentField.Key.ToAlias()}")
                                       .Searchable(true)
                                       .LinkedField(UuidUtil.GetId(Guid.Parse(dependentField.Value[FieldProperty.Id].ToString())).ToString()).Build().Content, new ReferenceInfo
                        {
                            MasterResource    = masterResource.Key,
                            DependentResource = dependentResource,
                            TargetFieldName   = dependentField.Key.Name,
                            TargetFieldType   = (TestCoreFramework.Enums.FieldType)Convert.ToInt32(dependentField.Value[FieldProperty.FieldType])
                        });
                    }

                    foreach (var createdField in ReferenceTargetFieldCreator.Data.Where(pair => (ResourceId)pair.Value[FieldProperty.Resource] == dependentResource))
                    {
                        request.Append(CreateFieldRequest.Builder().With(masterResource.Key, FieldType.Reference, $"{masterResource.Key}_{dependentResource}.{createdField.Value[FieldProperty.Name]}")
                                       .Searchable(true)
                                       .LinkedField(UuidUtil.GetId(Guid.Parse(createdField.Value[FieldProperty.Id].ToString())).ToString()).Build().Content, new ReferenceInfo
                        {
                            MasterResource    = masterResource.Key,
                            DependentResource = dependentResource,
                            TargetFieldName   = createdField.Value.Name,
                            TargetFieldType   = (TestCoreFramework.Enums.FieldType)Convert.ToInt32(createdField.Value[FieldProperty.FieldType])
                        });
                    }
                }
            }
            return(((CreateFieldsRequest.IBuilderWithRecord)request).Build().Content);
        }
Exemplo n.º 16
0
        public void TestUpdateField()
        {
            //Create some date field.
            var request1 = CreateFieldRequest.Builder()
                           .Resource(ResourceId.Job)
                           .Required(false)
                           .FieldType(FieldType.Date)
                           .DefaultValue(DateTime.Now.ToString("yyyy/MM/dd"))
                           .Searchable(false)
                           .JapaneseLabel("This is the first date field")
                           .JapaneseCaption("This is the first date field");
            var request2 = request1.JapaneseCaption("This is the second date field")
                           .JapaneseCaption("This is the second date field");
            Task <IdModel> result1 = session.CallAsync(request1.GetRequest());
            Task <IdModel> result2 = session.CallAsync(request2.GetRequest());

            TestContext.Out.WriteLine("Take a cup of coffee in meantime and wait for all tasks completes!");
            Task.WaitAll(result1, result2);
            TestContext.Out.WriteLine("Start to get the result !");
            Assume.That(result1.Result, Is.Not.Null, "Response data is null!");
            Assume.That(string.IsNullOrEmpty(result1.Result.Id), Is.False, "Id is null!");
            Assume.That(result2.Result, Is.Not.Null, "Response data is null!");
            Assume.That(string.IsNullOrEmpty(result2.Result.Id), Is.False, "Id is null!");

            fieldIdList.Add(result1.Result.Id);
            fieldIdList.Add(result2.Result.Id);

            var updateRequest = UpdateFieldRequest.Builder()
                                .Add(result1.Result.Id, UpdateFieldRequest.SingleFieldBuilder().JapaneseCaption("This is the first EDITED date field")
                                     .JapaneseLabel("This is the first EDITED date field"))
                                .Add(result2.Result.Id, UpdateFieldRequest.SingleFieldBuilder().JapaneseCaption("This is the second edited date field")
                                     .JapaneseLabel("This is the second edited date field"));
            var updateTask = session.CallAsync(updateRequest.GetRequest());

            Assert.That(updateTask.Result, Is.True, "Updating is not successful!");
        }
Exemplo n.º 17
0
 protected static CreateFieldRequest FieldCreateRequestFromSpec(FieldSpec spec)
 {
     return(CreateFieldRequest.Builder().With((ResourceId)(int)spec.Resource, (FieldType)(int)spec.FieldType, spec.Label == null ? spec.Key.ToString() : spec.Label).Build().Content);
 }