This commit is contained in:
48
DataList/Paging.cs
Normal file
48
DataList/Paging.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
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("Widget/listwidgets?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
|
||||||
235
User/UserCrud.cs
235
User/UserCrud.cs
@@ -474,152 +474,155 @@ namespace raven_integration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void UserPickListDefaultSortNoFilterWorks()
|
|
||||||
{
|
|
||||||
var RouteName = "User";//##########
|
|
||||||
|
|
||||||
//NOW FETCH LIST WITH FILTER
|
//DEPRECATED THESE BECAUSE THEY DON'T TEST ANYTHING UNIQUELY THAT ISN'T ALREADY COVERED BY THE DATALISTFILTER AND ORDER BY TESTS ELSEWHERE
|
||||||
ApiResponse a = await Util.GetAsync($"{RouteName}/picklist?Offset=0&Limit=999", await Util.GetTokenAsync("manager", "l3tm3in"));
|
//AND THE PICKLIST IS NOW MINI FORMAT OF REGULAR LIST
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// /// <summary>
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
// ///
|
||||||
|
// /// </summary>
|
||||||
|
// [Fact]
|
||||||
|
// public async void UserPickListDefaultSortNoFilterWorks()
|
||||||
|
// {
|
||||||
|
// var RouteName = "User";//##########
|
||||||
|
|
||||||
//assert contains at least 3 records
|
// //NOW FETCH LIST WITH FILTER
|
||||||
var ItemCount = ((JArray)a.ObjectResponse["data"]).Count;
|
// ApiResponse a = await Util.GetAsync($"{RouteName}/picklist?Offset=0&Limit=999", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
ItemCount.Should().BeGreaterOrEqualTo(3);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
|
// Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
var firstName = a.ObjectResponse["data"][0]["name"].Value<string>().Replace(" ", "");
|
// //assert contains at least 3 records
|
||||||
var secondName = a.ObjectResponse["data"][1]["name"].Value<string>().Replace(" ", "");
|
// var ItemCount = ((JArray)a.ObjectResponse["data"]).Count;
|
||||||
int comparison = String.Compare(firstName, secondName, comparisonType: StringComparison.OrdinalIgnoreCase);
|
// ItemCount.Should().BeGreaterOrEqualTo(3);
|
||||||
comparison.Should().BeNegative();
|
|
||||||
}
|
// var firstName = a.ObjectResponse["data"][0]["name"].Value<string>().Replace(" ", "");
|
||||||
|
// var secondName = a.ObjectResponse["data"][1]["name"].Value<string>().Replace(" ", "");
|
||||||
|
// int comparison = String.Compare(firstName, secondName, comparisonType: StringComparison.OrdinalIgnoreCase);
|
||||||
|
// comparison.Should().BeNegative();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
///
|
// ///
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async void UserPickListSortByFieldAscendingWorks()
|
// public async void UserPickListSortByFieldAscendingWorks()
|
||||||
{
|
// {
|
||||||
|
|
||||||
var NameStart = Util.Uniquify("UserPickListSortByFieldAscendingWorks");
|
// var NameStart = Util.Uniquify("UserPickListSortByFieldAscendingWorks");
|
||||||
|
|
||||||
//CREATE 3 TEST objects TO TEST ORDER
|
// //CREATE 3 TEST objects TO TEST ORDER
|
||||||
long FirstInOrderId = 0;
|
// long FirstInOrderId = 0;
|
||||||
long SecondInOrderId = 0;
|
// long SecondInOrderId = 0;
|
||||||
long ThirdInOrderId = 0;
|
// long ThirdInOrderId = 0;
|
||||||
|
|
||||||
dynamic d = new JObject();
|
// dynamic d = new JObject();
|
||||||
d.name = Util.Uniquify(NameStart);
|
// d.name = Util.Uniquify(NameStart);
|
||||||
d.active = false;
|
// d.active = false;
|
||||||
d.login = Util.Uniquify("LOGIN");
|
// d.login = Util.Uniquify("LOGIN");
|
||||||
d.password = Util.Uniquify("PASSWORD");
|
// d.password = Util.Uniquify("PASSWORD");
|
||||||
d.roles = 0;//norole
|
// d.roles = 0;//norole
|
||||||
d.localeId = 1;//random locale
|
// d.localeId = 1;//random locale
|
||||||
d.userType = 3;//non scheduleable
|
// d.userType = 3;//non scheduleable
|
||||||
//Required by form custom rules
|
// //Required by form custom rules
|
||||||
d.notes = "notes";
|
// d.notes = "notes";
|
||||||
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
// d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
|
|
||||||
ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
// ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
ThirdInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
// ThirdInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
d = new JObject();
|
// d = new JObject();
|
||||||
d.name = Util.Uniquify(NameStart);
|
// d.name = Util.Uniquify(NameStart);
|
||||||
d.active = true;
|
// d.active = true;
|
||||||
d.login = Util.Uniquify("LOGIN");
|
// d.login = Util.Uniquify("LOGIN");
|
||||||
d.password = Util.Uniquify("PASSWORD");
|
// d.password = Util.Uniquify("PASSWORD");
|
||||||
d.roles = 0;//norole
|
// d.roles = 0;//norole
|
||||||
d.localeId = 1;//random locale
|
// d.localeId = 1;//random locale
|
||||||
d.userType = 2;//non scheduleable
|
// d.userType = 2;//non scheduleable
|
||||||
//Required by form custom rules
|
// //Required by form custom rules
|
||||||
d.notes = "notes";
|
// d.notes = "notes";
|
||||||
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
// d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
// a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
SecondInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
// SecondInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
d = new JObject();
|
// d = new JObject();
|
||||||
d.name = Util.Uniquify(NameStart);
|
// d.name = Util.Uniquify(NameStart);
|
||||||
d.active = false;
|
// d.active = false;
|
||||||
d.login = Util.Uniquify("LOGIN");
|
// d.login = Util.Uniquify("LOGIN");
|
||||||
d.password = Util.Uniquify("PASSWORD");
|
// d.password = Util.Uniquify("PASSWORD");
|
||||||
d.roles = 0;//norole
|
// d.roles = 0;//norole
|
||||||
d.localeId = 1;//random locale
|
// d.localeId = 1;//random locale
|
||||||
d.userType = 1;//non scheduleable
|
// d.userType = 1;//non scheduleable
|
||||||
//Required by form custom rules
|
// //Required by form custom rules
|
||||||
d.notes = "notes";
|
// d.notes = "notes";
|
||||||
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
// d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||||
|
|
||||||
a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
// a = await Util.PostAsync("User", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
FirstInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
// FirstInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
|
|
||||||
//CREATE FILTER
|
// //CREATE FILTER
|
||||||
d = new JObject();
|
// d = new JObject();
|
||||||
d.name = Util.Uniquify(NameStart);
|
// d.name = Util.Uniquify(NameStart);
|
||||||
d["public"] = true;
|
// d["public"] = true;
|
||||||
d.listKey = "user";
|
// d.listKey = "user";
|
||||||
|
|
||||||
//FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
// //FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
||||||
dynamic dfilter = new JArray();
|
// dynamic dfilter = new JArray();
|
||||||
//name starts with filter to constrict to widgets that this test block created only
|
// //name starts with filter to constrict to widgets that this test block created only
|
||||||
dynamic DataFilterNameStart = new JObject();
|
// dynamic DataFilterNameStart = new JObject();
|
||||||
DataFilterNameStart.fld = "name";
|
// DataFilterNameStart.fld = "name";
|
||||||
DataFilterNameStart.op = Util.OpStartsWith;
|
// DataFilterNameStart.op = Util.OpStartsWith;
|
||||||
DataFilterNameStart.value = NameStart;
|
// DataFilterNameStart.value = NameStart;
|
||||||
dfilter.Add(DataFilterNameStart);
|
// dfilter.Add(DataFilterNameStart);
|
||||||
d.filter = dfilter.ToString();
|
// d.filter = dfilter.ToString();
|
||||||
|
|
||||||
//SORT ORDER ###################
|
// //SORT ORDER ###################
|
||||||
dynamic dsortarray = new JArray();
|
// dynamic dsortarray = new JArray();
|
||||||
dynamic dsort = new JObject();
|
// dynamic dsort = new JObject();
|
||||||
dsort.fld = "usertype";
|
// dsort.fld = "usertype";
|
||||||
dsort.dir = "+";
|
// dsort.dir = "+";
|
||||||
dsortarray.Add(dsort);
|
// dsortarray.Add(dsort);
|
||||||
d.sort = dsortarray.ToString();
|
// d.sort = dsortarray.ToString();
|
||||||
|
|
||||||
a = await Util.PostAsync("DataListFilter", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
// a = await Util.PostAsync("DataListFilter", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
|
|
||||||
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
// long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
|
||||||
//NOW FETCH WIDGET LIST WITH FILTER
|
// //NOW FETCH WIDGET LIST WITH FILTER
|
||||||
a = await Util.GetAsync($"User/picklist?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.GetAsync($"User/picklist?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
// Util.ValidateDataReturnResponseOk(a);
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
// Util.ValidateHTTPStatusCode(a, 200);
|
||||||
|
|
||||||
//assert contains exactly 3 records
|
// //assert contains exactly 3 records
|
||||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(3);
|
// ((JArray)a.ObjectResponse["data"]).Count.Should().Be(3);
|
||||||
|
|
||||||
//assert the order returned
|
// //assert the order returned
|
||||||
a.ObjectResponse["data"][0]["id"].Value<long>().Should().Be(FirstInOrderId);
|
// a.ObjectResponse["data"][0]["id"].Value<long>().Should().Be(FirstInOrderId);
|
||||||
a.ObjectResponse["data"][1]["id"].Value<long>().Should().Be(SecondInOrderId);
|
// a.ObjectResponse["data"][1]["id"].Value<long>().Should().Be(SecondInOrderId);
|
||||||
a.ObjectResponse["data"][2]["id"].Value<long>().Should().Be(ThirdInOrderId);
|
// a.ObjectResponse["data"][2]["id"].Value<long>().Should().Be(ThirdInOrderId);
|
||||||
|
|
||||||
|
|
||||||
a = await Util.DeleteAsync("User/" + FirstInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.DeleteAsync("User/" + FirstInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
// Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
a = await Util.DeleteAsync("User/" + SecondInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.DeleteAsync("User/" + SecondInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
// Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
a = await Util.DeleteAsync("User/" + ThirdInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.DeleteAsync("User/" + ThirdInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
// Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
//DELETE DATAFILTER
|
// //DELETE DATAFILTER
|
||||||
a = await Util.DeleteAsync("DataListFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
// a = await Util.DeleteAsync("DataListFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
// Util.ValidateHTTPStatusCode(a, 204);
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//==================================================
|
//==================================================
|
||||||
|
|||||||
@@ -1,220 +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 WidgetLists
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void WidgetPickListDefaultSortNoFilterWorks()
|
|
||||||
{
|
|
||||||
var RouteName = "Widget";//##########
|
|
||||||
|
|
||||||
//NOW FETCH LIST WITH FILTER
|
|
||||||
ApiResponse a = await Util.GetAsync($"{RouteName}/picklist?Offset=0&Limit=999", await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
|
|
||||||
//assert contains exactly 3 records
|
|
||||||
var ItemCount = ((JArray)a.ObjectResponse["data"]).Count;
|
|
||||||
|
|
||||||
for (int i = 0; i < ItemCount - 1; i++)
|
|
||||||
{
|
|
||||||
//Note it's necessary to replace the spaces because postgres thinks spaces go last and the string comparison thinks they go first
|
|
||||||
var firstName = a.ObjectResponse["data"][i]["name"].Value<string>().Replace(" ","");
|
|
||||||
var secondName = a.ObjectResponse["data"][i + 1]["name"].Value<string>().Replace(" ","");
|
|
||||||
int comparison = String.Compare(firstName, secondName, comparisonType: StringComparison.OrdinalIgnoreCase);
|
|
||||||
comparison.Should().BeNegative();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void WidgetPickListSortByFieldAscendingWorks()
|
|
||||||
{
|
|
||||||
|
|
||||||
var NameStart = Util.Uniquify("WidgetPickListSortByFieldAscendingWorks");
|
|
||||||
var RouteName = "Widget";
|
|
||||||
|
|
||||||
//CREATE 3 TEST OBJECTS TO TEST ORDER
|
|
||||||
long FirstInOrderId = 0;
|
|
||||||
long SecondInOrderId = 0;
|
|
||||||
long ThirdInOrderId = 0;
|
|
||||||
|
|
||||||
dynamic d = new JObject();
|
|
||||||
d.name = Util.Uniquify(NameStart);
|
|
||||||
d.notes="blah";
|
|
||||||
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
||||||
d.startDate = DateTime.Now;
|
|
||||||
d.endDate = DateTime.Now.AddHours(1);
|
|
||||||
|
|
||||||
ApiResponse a = await Util.PostAsync(RouteName, await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
FirstInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
||||||
|
|
||||||
d = new JObject();
|
|
||||||
d.name = Util.Uniquify(NameStart);
|
|
||||||
d.notes="blah";
|
|
||||||
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
||||||
d.startDate = DateTime.Now.AddHours(1);
|
|
||||||
d.endDate = DateTime.Now.AddHours(2);
|
|
||||||
a = await Util.PostAsync(RouteName, await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
SecondInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
||||||
|
|
||||||
d = new JObject();
|
|
||||||
d.name = Util.Uniquify(NameStart);
|
|
||||||
d.notes="blah";
|
|
||||||
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
||||||
d.startDate = DateTime.Now.AddHours(2);
|
|
||||||
d.endDate = DateTime.Now.AddHours(3);
|
|
||||||
a = await Util.PostAsync(RouteName, await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
ThirdInOrderId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
||||||
|
|
||||||
|
|
||||||
//CREATE FILTER
|
|
||||||
d = new JObject();
|
|
||||||
d.name = Util.Uniquify(NameStart);
|
|
||||||
d["public"] = true;
|
|
||||||
d.listKey="TestWidgetDataList";
|
|
||||||
|
|
||||||
//FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
|
||||||
dynamic dfilter = new JArray();
|
|
||||||
//name starts with filter to constrict to objects that this test block created only
|
|
||||||
dynamic DataFilterNameStart = new JObject();
|
|
||||||
DataFilterNameStart.fld = "name";
|
|
||||||
DataFilterNameStart.op = Util.OpStartsWith;
|
|
||||||
DataFilterNameStart.value = NameStart;
|
|
||||||
dfilter.Add(DataFilterNameStart);
|
|
||||||
d.filter = dfilter.ToString();
|
|
||||||
|
|
||||||
//SORT ORDER ###################
|
|
||||||
dynamic dsortarray = new JArray();
|
|
||||||
dynamic dsort = new JObject();
|
|
||||||
dsort.fld = "startdate";
|
|
||||||
dsort.dir = "+";
|
|
||||||
dsortarray.Add(dsort);
|
|
||||||
d.sort = dsortarray.ToString();
|
|
||||||
|
|
||||||
a = await Util.PostAsync("DataListFilter", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString());
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
|
|
||||||
long DataFilterId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
||||||
|
|
||||||
//NOW FETCH LIST WITH FILTER
|
|
||||||
a = await Util.GetAsync($"{RouteName}/picklist?Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
|
|
||||||
//assert contains exactly 3 records
|
|
||||||
((JArray)a.ObjectResponse["data"]).Count.Should().Be(3);
|
|
||||||
|
|
||||||
//assert the order returned
|
|
||||||
a.ObjectResponse["data"][0]["id"].Value<long>().Should().Be(FirstInOrderId);
|
|
||||||
a.ObjectResponse["data"][1]["id"].Value<long>().Should().Be(SecondInOrderId);
|
|
||||||
a.ObjectResponse["data"][2]["id"].Value<long>().Should().Be(ThirdInOrderId);
|
|
||||||
|
|
||||||
|
|
||||||
a = await Util.DeleteAsync($"{RouteName}/" + FirstInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
|
||||||
|
|
||||||
a = await Util.DeleteAsync($"{RouteName}/" + SecondInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
|
||||||
|
|
||||||
a = await Util.DeleteAsync($"{RouteName}/" + ThirdInOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
|
||||||
|
|
||||||
//DELETE DATAFILTER
|
|
||||||
a = await Util.DeleteAsync("DataListFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateHTTPStatusCode(a, 204);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Paging test
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void PagingShouldWorkAsExpected()
|
|
||||||
{
|
|
||||||
//Get all
|
|
||||||
ApiResponse a = await Util.GetAsync("Widget/listwidgets?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");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Fact]
|
|
||||||
public async void FilterOptionsRouteShouldWorkAsExpected()
|
|
||||||
{
|
|
||||||
//Get options with manager (english user)
|
|
||||||
ApiResponse a = await Util.GetAsync("Widget/FilterOptions", await Util.GetTokenAsync("manager", "l3tm3in"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
a.ObjectResponse["data"]["key"].Value<string>().Should().Be("widget");
|
|
||||||
((JArray)a.ObjectResponse["data"]["flds"]).Count.Should().Be(10);
|
|
||||||
|
|
||||||
int DollarAmountFieldNumber = 4;
|
|
||||||
|
|
||||||
a.ObjectResponse["data"]["flds"][DollarAmountFieldNumber]["lt"].Value<string>().Should().Be("Price");
|
|
||||||
|
|
||||||
a = await Util.GetAsync("Widget/FilterOptions", await Util.GetTokenAsync("es", "es"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
a.ObjectResponse["data"]["flds"][DollarAmountFieldNumber]["lt"].Value<string>().Should().Be("Importe");
|
|
||||||
|
|
||||||
a = await Util.GetAsync("Widget/FilterOptions", await Util.GetTokenAsync("fr", "fr"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
a.ObjectResponse["data"]["flds"][DollarAmountFieldNumber]["lt"].Value<string>().Should().Be("Montant");
|
|
||||||
|
|
||||||
a = await Util.GetAsync("Widget/FilterOptions", await Util.GetTokenAsync("de", "de"));
|
|
||||||
Util.ValidateDataReturnResponseOk(a);
|
|
||||||
Util.ValidateHTTPStatusCode(a, 200);
|
|
||||||
a.ObjectResponse["data"]["flds"][DollarAmountFieldNumber]["lt"].Value<string>().Should().Be("Betrag");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==================================================
|
|
||||||
|
|
||||||
}//eoc
|
|
||||||
}//eons
|
|
||||||
Reference in New Issue
Block a user