This commit is contained in:
2020-01-23 20:34:35 +00:00
parent 65de42a4dc
commit 406698ab54
2 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
namespace raven_integration
{
public class DataListMiniVariant
{
/// <summary>
///
/// </summary>
[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

View File

@@ -0,0 +1,29 @@
using Xunit;
using Newtonsoft.Json.Linq;
using FluentAssertions;
namespace raven_integration
{
public class DataListRights
{
/// <summary>
///
/// </summary>
[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