public static PrivateData <Dictionary <TestCoreFramework.Enums.ResourceType, Guid> > PreapreFieldLayouts(HrbcFieldCreator fieldsCreator) { return(new PrivateData <Dictionary <TestCoreFramework.Enums.ResourceType, Guid> >( (session, test) => { return Task.Run(() => { var result = new Dictionary <TestCoreFramework.Enums.ResourceType, Guid>(); foreach (TestCoreFramework.Enums.ResourceType resource in Enum.GetValues(typeof(TestCoreFramework.Enums.ResourceType))) { var fieldManager = new FieldManager(); var createSectionResponse = fieldManager.CreateSection(resource); PrAssume.That(createSectionResponse, PrIs.SuccessfulResponse <Dictionary <string, Guid> >()); var unusedFieldsSectionResponnse = fieldManager.GetUnusedFieldsSectionDetails(resource); PrAssume.That(unusedFieldsSectionResponnse, PrIs.SuccessfulResponse <GetLayoutResponse>()); UnusedSections[resource] = unusedFieldsSectionResponnse.Result; var appFieldsToActivate = fieldManager.GetFieldGuid(AppFields.Select(x => x.Value).ToArray(), new[] { resource }).Result; var userFieldsToActivate = fieldsCreator.Data.Where(x => ((FieldDescriptor)x.Key).Resource == resource.ToPrivateApiResource()).Select(x => x.Value.Guid); var sysFieldsToActivate = fieldManager.GetFieldGuid(MoveMissingFieldToLayout[resource.ToPrivateApiResource()], new[] { resource }).Result; var guids = fieldsCreator.Data.Where(x => ((FieldDescriptor)x.Key).Resource == resource.ToPrivateApiResource()).Select(x => x.Value.Guid) .Concat(appFieldsToActivate.Result.Select(x => x.Id)) .Concat(userFieldsToActivate); if (MoveMissingFieldToLayout[resource.ToPrivateApiResource()].Count() != 0) { guids = guids.Concat(sysFieldsToActivate.Result.Select(x => x.Id)); } var setLayoutResponse = fieldManager.MakeFieldsActive(resource, guids.ToArray(), UnusedSections[resource].Values.First().Value, createSectionResponse.Result.Single().Value); PrAssume.That(setLayoutResponse, PrIs.SuccessfulResponse()); result[resource] = createSectionResponse.Result["id"]; } return result; }); }, (session, test, ids) => { return Task.Run(() => { foreach (var id in ids) { var setFieldsReqeust = new SetLayoutRequest { Values = new Dictionary <Guid, LayoutItem> { [UnusedSections[id.Key].Values.First().Key] = new LayoutItem { Id = UnusedSections[id.Key].Values.First().Key, Cells = UnusedSections[id.Key].Values.First().Value.Cells }, [id.Value] = new LayoutItem { Id = id.Value, Cells = new List <CellItem>() } } }; var handler = new DefaultManager(); var response = handler.Send(setFieldsReqeust); PrAssume.That(response, PrIs.SuccessfulResponse()); response = handler.Send(FieldManager.FieldLayoutApiRelativeUrl, new Dictionary <string, string> { ["id[0]"] = id.Value.ToString() }, TestCoreFramework.Enums.HttpMethod.DELETE); PrAssume.That(response, PrIs.SuccessfulResponse()); } }); } )); }