From 406698ab540ebbec4a9ef3e92e5a56379b04983e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 23 Jan 2020 20:34:35 +0000 Subject: [PATCH] --- DataList/DataListMiniVariant.cs | 56 +++++++++++++++++++++++++++++++++ DataList/DataListRights.cs | 29 +++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 DataList/DataListMiniVariant.cs create mode 100644 DataList/DataListRights.cs diff --git a/DataList/DataListMiniVariant.cs b/DataList/DataListMiniVariant.cs new file mode 100644 index 0000000..5bc3b45 --- /dev/null +++ b/DataList/DataListMiniVariant.cs @@ -0,0 +1,56 @@ +using Xunit; +using Newtonsoft.Json.Linq; +using FluentAssertions; + +namespace raven_integration +{ + + public class DataListMiniVariant + { + + + /// + /// + /// + [Fact] + public async void ListShouldFetchAsMiniVersion() + { + //Get without rights + /* + "{\"data\":[ + [{\"v\":1},{\"v\":\"Handcrafted Concrete Chicken 76\",\"i\":1},{\"v\":1}], + [{\"v\":2},{\"v\":\"Fantastic Cotton Chicken 77\",\"i\":2},{\"v\":2}], + [{\"v\":3},{\"v\":\"Generic Concrete Ball 78\",\"i\":3},{\"v\":3}] + ], + \"paging\":{\"count\":513,\"offset\":0,\"limit\":3,\"first\":\"http://localhost:7575/api/v8/DataList/List?pageNo=1&pageSize=3\",\"previous\":null,\"next\":\"http://localhost:7575/api/v8/DataList/List?pageNo=1&pageSize=3\",\"last\":\"http://localhost:7575/api/v8/DataList/List?pageNo=171&pageSize=3\"}, + \"columns\":\"[ + {\\\"cm\\\":\\\"df\\\",\\\"dt\\\":0,\\\"ay\\\":2}, + {\\\"cm\\\":\\\"Widget\\\",\\\"dt\\\":4,\\\"ay\\\":2} + ]\"}" + */ + ApiResponse a = await Util.GetAsync("DataList/list?DataListKey=TestWidgetDataList&Offset=0&Limit=3&Mini=true", await Util.GetTokenAsync("manager", "l3tm3in")); + Util.ValidateDataReturnResponseOk(a); + + + //Assert the data array + + //Data array should contain 3 arrays + var rows = ((JArray)a.ObjectResponse["data"]); + rows.Count.Should().Be(3); + //each array inside data array should have three objects + foreach (JArray row in rows) + { + row.Count.Should().Be(3); + } + + //assert the columns array + //the columns property should define two columns and the first should be df and the second should be Widget dt4 + var columns = ((JArray)a.ObjectResponse["columns"]); + columns.Count.Should().Be(2); + + } + + //================================================== + + }//eoc +}//eons diff --git a/DataList/DataListRights.cs b/DataList/DataListRights.cs new file mode 100644 index 0000000..3bc3841 --- /dev/null +++ b/DataList/DataListRights.cs @@ -0,0 +1,29 @@ +using Xunit; +using Newtonsoft.Json.Linq; +using FluentAssertions; + +namespace raven_integration +{ + + public class DataListRights + { + + + /// + /// + /// + [Fact] + public async void InsufficentRightsShouldNotRetrieve() + { + //Get without rights + /* + "{\"error\":{\"code\":\"2004\",\"message\":\"User not authorized for this resource operation (insufficient rights)\"}}" + */ + ApiResponse a = await Util.GetAsync("DataList/list?DataListKey=TestWidgetDataList&Offset=0&Limit=3", await Util.GetTokenAsync("CustomerLimited")); + Util.ValidateErrorCodeResponse(a, 2004, 403); + } + + //================================================== + + }//eoc +}//eons