diff --git a/DataList/DataListMiniVariant.cs b/DataList/DataListMiniVariant.cs index eea262b..fd6ebd0 100644 --- a/DataList/DataListMiniVariant.cs +++ b/DataList/DataListMiniVariant.cs @@ -14,9 +14,9 @@ namespace raven_integration /// [Fact] public async void ListShouldFetchAsMiniVersion() - { + { - ApiResponse a = await Util.GetAsync("DataList/list?DataListKey=TestWidgetDataList&Offset=0&Limit=3&mini=true", await Util.GetTokenAsync("manager", "l3tm3in")); + ApiResponse a = await Util.PostAsync($"DataList", await Util.GetTokenAsync("manager", "l3tm3in"), Util.BuildDataListRequest(null, null, 3, 0, true)); Util.ValidateDataReturnResponseOk(a); diff --git a/DataList/DataListReturnFormat.cs b/DataList/DataListReturnFormat.cs new file mode 100644 index 0000000..945e02e --- /dev/null +++ b/DataList/DataListReturnFormat.cs @@ -0,0 +1,40 @@ +using System; +using Xunit; +using Newtonsoft.Json.Linq; +using FluentAssertions; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Collections.Concurrent; + +namespace raven_integration +{ + + public class DataListPaging + { + + + /// + /// Return format test + /// + [Fact] + public async void DataListReturnFormatShouldWorkAsExpected() + { + + ApiResponse a = await Util.PostAsync($"DataList", await Util.GetTokenAsync("manager", "l3tm3in"), Util.BuildDataListRequest(null, null, 3, 2)); + Util.ValidateDataReturnResponseOk(a); + Util.ValidateHTTPStatusCode(a, 200); + + //assert aAll contains at least three records + ((JArray)a.ObjectResponse["data"]).Count.Should().Be(3); + //sb a total record count greater than 3 + ((JValue)a.ObjectResponse["totalRecordCount"]).Value().Should().BeGreaterThan(3); + //sb a column header collection greater than 3 + ((JArray)a.ObjectResponse["columns"]).Count.Should().BeGreaterThan(3); + + } + + + //================================================== + + }//eoc +}//eons diff --git a/DataList/DataListRights.cs b/DataList/DataListRights.cs index 3bc3841..f7c02d5 100644 --- a/DataList/DataListRights.cs +++ b/DataList/DataListRights.cs @@ -19,7 +19,8 @@ namespace raven_integration /* "{\"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")); + //ApiResponse a = await Util.GetAsync("DataList/list?DataListKey=TestWidgetDataList&Offset=0&Limit=3", await Util.GetTokenAsync("CustomerLimited")); + ApiResponse a = await Util.PostAsync($"DataList", await Util.GetTokenAsync("CustomerLimited"), Util.BuildDataListRequest()); Util.ValidateErrorCodeResponse(a, 2004, 403); } diff --git a/DataList/Paging.cs b/DataList/Paging.cs deleted file mode 100644 index 53bbceb..0000000 --- a/DataList/Paging.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Xunit; -using Newtonsoft.Json.Linq; -using FluentAssertions; -using System.Collections.Generic; -using System.Threading.Tasks; -using System.Collections.Concurrent; - -namespace raven_integration -{ - - public class DataListPaging - { - - - /// - /// Paging test - /// - [Fact] - public async void PagingShouldWorkAsExpected() - { - //Get all - ApiResponse a = await Util.GetAsync("DataList/list?DataListKey=TestWidgetDataList&Offset=2&Limit=3", await Util.GetTokenAsync("manager", "l3tm3in")); - Util.ValidateDataReturnResponseOk(a); - Util.ValidateHTTPStatusCode(a, 200); - - //assert aAll contains at least two records - ((JArray)a.ObjectResponse["data"]).Count.Should().Be(3); - - JObject jp = (JObject)a.ObjectResponse["paging"]; - jp["count"].Value().Should().BeGreaterThan(5); - jp["offset"].Value().Should().Be(2); - jp["limit"].Value().Should().Be(3); - jp["first"].Value().Should().EndWith("&pageSize=3"); - jp["previous"].Value().Should().EndWith("&pageSize=3"); - jp["next"].Value().Should().EndWith("&pageSize=3"); - jp["last"].Value().Should().EndWith("&pageSize=3"); - } - - - - - - - //================================================== - - }//eoc -}//eons diff --git a/util.cs b/util.cs index cf95550..a2b384e 100644 --- a/util.cs +++ b/util.cs @@ -587,7 +587,7 @@ namespace raven_integration } - public static string BuildDataListRequest(dynamic dFilter, dynamic dSort=null, int limit = 999, int offset = 0, bool mini = false, string dataListKey = "TestWidgetDataList") + public static string BuildDataListRequest(dynamic dFilter = null, dynamic dSort = null, int limit = 999, int offset = 0, bool mini = false, string dataListKey = "TestWidgetDataList") { /* { @@ -604,7 +604,8 @@ namespace raven_integration d.limit = limit; d.mini = mini; d.dataListKey = dataListKey; - d.filterJson = dFilter.ToString(); + if (dFilter != null) + d.filterJson = dFilter.ToString(); if (dSort != null) d.sortJson = dSort.ToString(); return d.ToString();