public async Task CreatesFieldWithAlias() { // create request var builer = GetFieldLayoutRequest.Builder(); builer.AppendId("00000000-0000-07d1-4009-00000000058d"); var request = builer.Build().Content; //Get session using (var client = PrivateClient.CreateClient(new PrivateServerSettings() { ServerUrl = server, LoggerFactory = TestLoggerFactoryAttribute.CurrentLoggerFactory })) using (var session = client.CreateSession(auth)) { //Send Request var fields = await session.CallAsync(builer.Build()); Assert.That(fields, Is.Not.Null, "fields is null or empty!"); Assert.That(fields.Data, Is.Not.Null, "Fields is null or empty!"); Assert.That(fields.Data.Values, Is.Not.Null.And.Not.Empty, "Fields.Values is null or empty!"); Assert.That(fields.Data.Values.Single(), Is.Not.Null, "Values.Single is null or empty!"); Assert.That(fields.Data.Values.Single().Cells, Is.Not.Null.And.Not.Empty, "Cells is null or empty!"); Assert.That(fields.Data.Values.Single().Cells.First(), Is.Not.Null, "First Cell is null or empty!"); Assert.That(fields.Data.Values.Single().Cells.First().Content, Is.Not.Null, "First cell content is null or empty!"); Assert.That(fields.Data.Values.Single().Cells.First().Content.First().Key, Is.Not.Null.And.Not.Empty.And.EqualTo("field"), "Content key is null or empty or field!"); Assert.That(fields.Data.Values.Single().Cells.First().Content.First().Value.ToString(), Is.EqualTo("00000000-0000-2c7e-4000-00050000058d"), "content value is null or empty!"); } }
ReadFields(IEnumerable <Guid> guids, IEnumerable <FieldProperty> select) { return(async(session, test) => { var fieldContainer = await session.CallAsync(GetFieldLayoutRequest.Builder().AppendIds(guids).Recursive(true)); var fields = fieldContainer.Data.ToDictionary(x => x.Key, x => x.Value.Cells.Select(cell => cell.Content["field"]).ToList()); Assume.That(fields, Has.Count.GreaterThanOrEqualTo(guids.Distinct().Count()), "not all fields were found, check for typoes"); var data = await session.CallAsync(FieldRequest.GetFields().Select(select).WhereGuid(fields.Values.SelectMany(x => x).ToArray())); return data; }); }