414 lines
18 KiB
C#
414 lines
18 KiB
C#
// using System;
|
|
// using Xunit;
|
|
// using Newtonsoft.Json.Linq;
|
|
// using FluentAssertions;
|
|
// using System.Collections.Generic;
|
|
// using System.Collections.Concurrent;
|
|
|
|
// namespace raven_integration
|
|
// {
|
|
|
|
|
|
// public class DataListSorting
|
|
// {
|
|
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// [Fact]
|
|
// public async Task DefaultSortByIdWorks()
|
|
// {
|
|
|
|
// var WidgetNameStart = Util.Uniquify("DefaultSortByIdWorks");
|
|
|
|
// //CREATE 3 TEST WIDGETS TO TEST ORDER
|
|
// long FirstInOrderWidgetId = 0;
|
|
// long SecondInOrderWidgetId = 0;
|
|
// long ThirdInOrderWidgetId = 0;
|
|
|
|
// dynamic w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.usertype = 1;
|
|
// ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// ThirdInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// SecondInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// FirstInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
|
|
// //CREATE FILTER
|
|
|
|
// dynamic dListView = new JArray();
|
|
|
|
|
|
// //name starts with filter to constrict to widgets that this test block created only
|
|
|
|
// dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpStartsWith, WidgetNameStart));
|
|
|
|
// //NOW FETCH WIDGET LIST WITH FILTER
|
|
// // a = await Util.GetAsync($"data-list/list?DataListKey=TestWidgetDataList&Offset=0&Limit=999&DataFilterId={DataFilterId.ToString()}", await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
|
|
// 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][0]["i"].Value<long>().Should().Be(FirstInOrderWidgetId);
|
|
// a.ObjectResponse["data"][1][0]["i"].Value<long>().Should().Be(SecondInOrderWidgetId);
|
|
// a.ObjectResponse["data"][2][0]["i"].Value<long>().Should().Be(ThirdInOrderWidgetId);
|
|
|
|
|
|
// a = await Util.DeleteAsync("widget/" + FirstInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + SecondInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + ThirdInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
// }
|
|
|
|
|
|
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// [Fact]
|
|
// public async Task SortByFieldAscendingWorks()
|
|
// {
|
|
|
|
// var WidgetNameStart = Util.Uniquify("SortByFieldAscendingWorks");
|
|
|
|
// //CREATE 3 TEST WIDGETS TO TEST ORDER
|
|
// long FirstInOrderWidgetId = 0;
|
|
// long SecondInOrderWidgetId = 0;
|
|
// long ThirdInOrderWidgetId = 0;
|
|
|
|
// dynamic w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.startDate = DateTime.Now;
|
|
// w.endDate = DateTime.Now.AddHours(1);
|
|
// w.usertype = 1;
|
|
|
|
// ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// FirstInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.startDate = DateTime.Now.AddHours(1);
|
|
// w.endDate = DateTime.Now.AddHours(2);
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// SecondInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.startDate = DateTime.Now.AddHours(2);
|
|
// w.endDate = DateTime.Now.AddHours(3);
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// ThirdInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
|
|
// //CREATE FILTER
|
|
// //FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
|
// dynamic dListView = new JArray();
|
|
// //name starts with filter to constrict to widgets that this test block created only
|
|
|
|
|
|
// //SORT ORDER ###################
|
|
// // dynamic dsortarray = new JArray();
|
|
// // dynamic dsort = new JObject();
|
|
// // dsort.fld = "widgetstartdate";
|
|
// // dsort.dir = "+";
|
|
// // dsortarray.Add(dsort);
|
|
|
|
// //both conditions filter and sort here
|
|
// dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpStartsWith, WidgetNameStart, "+"));
|
|
|
|
|
|
|
|
// //NOW FETCH WIDGET LIST WITH FILTER
|
|
// a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
|
|
// 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][0]["i"].Value<long>().Should().Be(FirstInOrderWidgetId);
|
|
// a.ObjectResponse["data"][1][0]["i"].Value<long>().Should().Be(SecondInOrderWidgetId);
|
|
// a.ObjectResponse["data"][2][0]["i"].Value<long>().Should().Be(ThirdInOrderWidgetId);
|
|
|
|
|
|
// a = await Util.DeleteAsync("widget/" + FirstInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + SecondInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + ThirdInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// [Fact]
|
|
// public async Task SortByFieldDescendingWorks()
|
|
// {
|
|
|
|
// var WidgetNameStart = Util.Uniquify("SortByFieldDescendingWorks");
|
|
|
|
// //CREATE 3 TEST WIDGETS TO TEST ORDER
|
|
// long FirstInOrderWidgetId = 0;
|
|
// long SecondInOrderWidgetId = 0;
|
|
// long ThirdInOrderWidgetId = 0;
|
|
|
|
// dynamic w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.count = 999;
|
|
// w.usertype = 1;
|
|
|
|
// ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// FirstInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.count = 665;
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// SecondInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.count = 333;
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// ThirdInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
|
|
// //CREATE FILTER
|
|
|
|
// //FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
|
// dynamic dListView = new JArray();
|
|
// //name starts with filter to constrict to widgets that this test block created only
|
|
|
|
// dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpStartsWith, WidgetNameStart));
|
|
|
|
|
|
// //SORT ORDER ###################
|
|
// // dynamic dsortarray = new JArray();
|
|
// // dynamic dsort = new JObject();
|
|
// // dsort.fld = "widgetcount";
|
|
// // dsort.dir = "-";
|
|
// dListView.Add(Util.BuildSimpleSortDataListViewColumn("widgetcount", "-"));
|
|
|
|
// //NOW FETCH WIDGET LIST WITH FILTER
|
|
// a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
|
|
// 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][0]["i"].Value<long>().Should().Be(FirstInOrderWidgetId);
|
|
// a.ObjectResponse["data"][1][0]["i"].Value<long>().Should().Be(SecondInOrderWidgetId);
|
|
// a.ObjectResponse["data"][2][0]["i"].Value<long>().Should().Be(ThirdInOrderWidgetId);
|
|
|
|
|
|
// a = await Util.DeleteAsync("widget/" + FirstInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + SecondInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + ThirdInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// /// <summary>
|
|
// ///
|
|
// /// </summary>
|
|
// [Fact]
|
|
// public async Task SortByMultipleFieldsWorks()
|
|
// {
|
|
// /*
|
|
|
|
// Created order:
|
|
// dollaramount, count
|
|
// 2,1
|
|
// 1,2
|
|
// 2,2
|
|
// 1,1
|
|
|
|
|
|
// sorted order:
|
|
// dollar asc, count desc
|
|
// 1,2
|
|
// 1,1
|
|
// 2,2
|
|
// 2,1
|
|
|
|
// */
|
|
// var WidgetNameStart = Util.Uniquify("SortByMultipleFieldsWorks");
|
|
|
|
// //CREATE 4 TEST WIDGETS TO TEST ORDER
|
|
// long FirstInOrderWidgetId = 0;
|
|
// long SecondInOrderWidgetId = 0;
|
|
// long ThirdInOrderWidgetId = 0;
|
|
// long FourthInOrderWidgetId = 0;
|
|
|
|
// dynamic w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.dollaramount = 2.22;
|
|
// w.count = 1;
|
|
// w.usertype = 1;
|
|
|
|
// ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// FourthInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.dollaramount = 1.11;
|
|
// w.count = 2;
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// FirstInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.dollaramount = 1.11;
|
|
// w.count = 1;
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// SecondInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
// w = new JObject();
|
|
// w.name = Util.Uniquify(WidgetNameStart);
|
|
// w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
|
// w.notes = "blah";
|
|
// w.dollaramount = 2.22;
|
|
// w.count = 2;
|
|
// w.usertype = 1;
|
|
// a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// ThirdInOrderWidgetId = a.ObjectResponse["data"]["id"].Value<long>();
|
|
|
|
|
|
// //CREATE FILTER
|
|
|
|
// //FILTER IN BY NAME FOR TESTING THIS RUN ONLY
|
|
// dynamic dListView = new JArray();
|
|
// //name starts with filter to constrict to widgets that this test block created only
|
|
// dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetname", Util.OpStartsWith, WidgetNameStart));
|
|
|
|
// //SORT ORDER ###################
|
|
// // dynamic dsortarray = new JArray();
|
|
|
|
// //First column
|
|
// // dynamic dsort1 = new JObject();
|
|
// // dsort1.fld = "widgetdollaramount";
|
|
// // dsort1.dir = "+";
|
|
// // dsortarray.Add(dsort1);
|
|
// dListView.Add(Util.BuildSimpleSortDataListViewColumn("widgetdollaramount", "+"));
|
|
|
|
// //Second column
|
|
// // dynamic dsort2 = new JObject();
|
|
// // dsort2.fld = "widgetcount";
|
|
// // dsort2.dir = "-";
|
|
// // dsortarray.Add(dsort2);
|
|
// dListView.Add(Util.BuildSimpleSortDataListViewColumn("widgetcount", "-"));
|
|
|
|
|
|
// //NOW FETCH WIDGET LIST WITH FILTER
|
|
// a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
|
|
// Util.ValidateDataReturnResponseOk(a);
|
|
// Util.ValidateHTTPStatusCode(a, 200);
|
|
|
|
// //assert contains exactly 3 records
|
|
// ((JArray)a.ObjectResponse["data"]).Count.Should().Be(4);
|
|
|
|
// //assert the order returned
|
|
// a.ObjectResponse["data"][0][0]["i"].Value<long>().Should().Be(FirstInOrderWidgetId);
|
|
// a.ObjectResponse["data"][1][0]["i"].Value<long>().Should().Be(SecondInOrderWidgetId);
|
|
// a.ObjectResponse["data"][2][0]["i"].Value<long>().Should().Be(ThirdInOrderWidgetId);
|
|
// a.ObjectResponse["data"][3][0]["i"].Value<long>().Should().Be(FourthInOrderWidgetId);
|
|
|
|
|
|
// a = await Util.DeleteAsync("widget/" + FirstInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + SecondInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + ThirdInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// a = await Util.DeleteAsync("widget/" + FourthInOrderWidgetId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
|
|
// Util.ValidateHTTPStatusCode(a, 204);
|
|
|
|
// }
|
|
|
|
// //========================================================================
|
|
|
|
// }//eoc
|
|
// }//eons
|