Exemplo n.º 1
0
        public void TestValidUpdateSystemFieldLayout(ResourceId resourceId, string field, Title title, UpdateCellLayout cellLayout, UpdateCellContent cellContent)
        {
            var fieldHandler  = new FieldManager();
            var fieldResponse = fieldHandler.GetFieldGuid(new[] { field }, new[] { resourceId });

            PrAssume.That(fieldResponse, PrIs.SuccessfulResponse(), $"Cannot read field {field}");
            var fieldUuid = fieldResponse.Result.Result.First().Id;
            var handler   = new DefaultManager();
            var request   = GenerateUpdateFieldLayoutRequest(resourceId, LayoutUuids[resourceId], fieldUuid, title, cellLayout, cellContent);
            var response  = handler.Send <FieldCreateResponse>(FieldManager.FieldLayoutApiRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PerformTest(title, request, response, fieldUuid, LayoutUuids[resourceId], false);
        }
        public void TestValidUpdateApplicationFieldLayout(ResourceId resourceId, Title title, UpdateCellLayout cellLayout, UpdateCellContent cellContent)
        {
            var handler  = new DefaultManager();
            var request  = GenerateUpdateFieldLayoutRequest(resourceId, LayoutUuids[resourceId], FieldUuids[resourceId], title, cellLayout, cellContent);
            var response = handler.Send <FieldCreateResponse>(FieldManager.FieldLayoutApiRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PerformTest(title, request, response, FieldUuids[resourceId], LayoutUuids[resourceId], false);
        }
        public void TestValidUpdateUserFieldLayout(ResourceId resourceId, Title title, UpdateCellLayout cellLayout, UpdateCellContent cellContent)
        {
            var handler   = new DefaultManager();
            var fieldUuid = FieldsCreator.Data[$"{resourceId}-{FieldType.SingleLineText.ToString()}-0"].Guid;
            var request   = GenerateUpdateFieldLayoutRequest(resourceId, LayoutUuids[resourceId], fieldUuid, title, cellLayout, cellContent);
            var response  = handler.Send <FieldCreateResponse>(FieldManager.FieldLayoutApiRelativeUrl, JsonConvert.SerializeObject(request), HttpMethod.PUT);

            PerformTest(title, request, response, fieldUuid, LayoutUuids[resourceId], false);
        }
Exemplo n.º 4
0
        public static Dictionary <string, object> GenerateUpdateFieldLayoutRequest(ResourceId resource, Guid layoutId, Guid uuid, Title title, UpdateCellLayout cellLayout, UpdateCellContent cellContent)
        {
            var props = new Dictionary <string, object>();

            TitleMapperValue[title](props);

            var content = new Dictionary <string, object>
            {
                [Cell.Content.GetEnumStringValue()] = new Dictionary <string, object>
                {
                    [cellContent.GetEnumStringValue()] = uuid.ToString()
                }
            };

            UpdateCellContentMapperValue[cellContent](content, uuid);

            var cContent = new Dictionary <string, object>
            {
                [Cell.Rows.GetEnumStringValue()] = 1,
                [Cell.Cols.GetEnumStringValue()] = 1,
                [Cell.X.GetEnumStringValue()]    = 1,
                [Cell.Y.GetEnumStringValue()]    = 1
            };

            if (cellLayout != UpdateCellLayout.Missing)
            {
                var cellContentMerged = cContent.Union(content).ToDictionary(x => x.Key, x => x.Value);
                UpdateCellLayoutMapperValue[cellLayout](cellContentMerged);
                props[Parameters.Cells.GetEnumStringValue()] = new List <Dictionary <string, object> >
                {
                    cellContentMerged
                };
            }

            return(new Dictionary <string, object>
            {
                [UpdateParameters.Update.GetEnumStringValue()] = new Dictionary <string, object>
                {
                    [layoutId.ToString()] = props
                }
            });
        }