This commit is contained in:
@@ -14,9 +14,9 @@ namespace raven_integration
|
||||
/// </summary>
|
||||
[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);
|
||||
|
||||
|
||||
|
||||
40
DataList/DataListReturnFormat.cs
Normal file
40
DataList/DataListReturnFormat.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Return format test
|
||||
/// </summary>
|
||||
[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<long>().Should().BeGreaterThan(3);
|
||||
//sb a column header collection greater than 3
|
||||
((JArray)a.ObjectResponse["columns"]).Count.Should().BeGreaterThan(3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Paging test
|
||||
/// </summary>
|
||||
[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<long>().Should().BeGreaterThan(5);
|
||||
jp["offset"].Value<int>().Should().Be(2);
|
||||
jp["limit"].Value<int>().Should().Be(3);
|
||||
jp["first"].Value<string>().Should().EndWith("&pageSize=3");
|
||||
jp["previous"].Value<string>().Should().EndWith("&pageSize=3");
|
||||
jp["next"].Value<string>().Should().EndWith("&pageSize=3");
|
||||
jp["last"].Value<string>().Should().EndWith("&pageSize=3");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
5
util.cs
5
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();
|
||||
|
||||
Reference in New Issue
Block a user