4648
This commit is contained in:
@@ -1,221 +1,221 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class EventLog
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void ObjectLogWorks()
|
||||
{
|
||||
//CRUD a widget and confirm it logs properly
|
||||
//http://localhost:7575/api/v8.0/event-log/userlog?AyType=3&AyId=1
|
||||
//http://localhost:7575/api/v8.0/event-log/objectlog?AyType=2&AyId=242
|
||||
//http://localhost:7575/api/v8.0/event-log/userlog?AyType=3&AyId=1&StartDate=2018-08-23&EndDate=2018-08-24
|
||||
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify("EventLog Test WIDGET");
|
||||
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
w.notes = "blah";
|
||||
w.created = DateTime.Now.ToString();
|
||||
w.dollarAmount = 2.22m;
|
||||
w.active = true;
|
||||
w.usertype = 1;
|
||||
|
||||
//*** CREATED
|
||||
ApiResponse r2 = await Util.PostAsync("widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(r2);
|
||||
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
ApiResponse EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);//only one event so far
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(1);//AyEvent 1 = created
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
//Get current user doing modifications ID
|
||||
long CurrentUserId = EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Value<long>();
|
||||
|
||||
//*** RETRIEVED
|
||||
//Get one
|
||||
ApiResponse r3 = await Util.GetAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateDataReturnResponseOk(r3);
|
||||
r3.ObjectResponse["data"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||
w = r3.ObjectResponse["data"];
|
||||
|
||||
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
//confirm event count, type and sort order (descending by date most recent first)
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(2);
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(2);//AyEvent 2 = retrieved
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
//*** MODIFIED
|
||||
//PUT
|
||||
//update w2id
|
||||
w.name = Util.Uniquify("UPDATED VIA PUT EVENTLOG TEST WIDGET");
|
||||
w.UserId = 1;
|
||||
w.concurrency = r2.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
//*** RETRIEVED
|
||||
//check PUT worked
|
||||
ApiResponse checkPUTWorked = await Util.GetAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||
checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||
uint concurrency = PUTTestResponse.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(4);
|
||||
//put op is the second item in the list, top item is the recent fetch
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["event"].Value<int>().Should().Be(3);//AyEvent 3 = Modified
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
|
||||
//Check user log for basic accessibility userlog?UserId=7
|
||||
EventLogResponse = await Util.GetAsync($"event-log/userlog?UserId={CurrentUserId}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().BeGreaterOrEqualTo(4);//just one run of the above will be 4 events plus any others from other tests
|
||||
//Not sure of any easy way to assert the User log is correct other than the count as other tests running concurrently could easily skew this
|
||||
|
||||
|
||||
//DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
//All events should be cleared up on deletion with the sole exception of the deleted event
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(0);//AyEvent 0 = deleted
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Value<string>().Should().Be(w.name.ToString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void UserLogWorks()
|
||||
{
|
||||
//get admin log, sb lots of shit
|
||||
ApiResponse a = await Util.GetAsync($"event-log/userlog?UserId=1&Offset=0&Limit=999", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().BeGreaterThan(90);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async void EventLogLimitOffSetWorks()
|
||||
{
|
||||
|
||||
var UniqueName = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = UniqueName;
|
||||
|
||||
d.active = true;
|
||||
d.login = UniqueName;
|
||||
d.password = UniqueName;
|
||||
d.roles = 2;//bizadminfull needs widget rights
|
||||
d.userType = 3;//non scheduleable
|
||||
|
||||
//Required by form custom rules
|
||||
d.notes = "notes";
|
||||
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||
|
||||
ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long UserId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//Loop and make 10 widgets
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
d = new JObject();
|
||||
d.name = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
d.dollarAmount = 1.11m;
|
||||
d.active = true;
|
||||
d.usertype = 1;
|
||||
d.notes = "note here";
|
||||
a = await Util.PostAsync("widget", await Util.GetTokenAsync(UniqueName, UniqueName), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=0&Limit=9", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(9);
|
||||
//capture events, then compare to paged ones
|
||||
var eventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
List<string> allEvents = new List<string>(9);
|
||||
foreach (JObject o in eventList)
|
||||
{
|
||||
allEvents.Add(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=0&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
var pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=1&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=2&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
using System;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FluentAssertions;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace raven_integration
|
||||
{
|
||||
|
||||
public class EventLog
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task ObjectLogWorks()
|
||||
{
|
||||
//CRUD a widget and confirm it logs properly
|
||||
//http://localhost:7575/api/v8.0/event-log/userlog?AyType=3&AyId=1
|
||||
//http://localhost:7575/api/v8.0/event-log/objectlog?AyType=2&AyId=242
|
||||
//http://localhost:7575/api/v8.0/event-log/userlog?AyType=3&AyId=1&StartDate=2018-08-23&EndDate=2018-08-24
|
||||
|
||||
dynamic w = new JObject();
|
||||
w.name = Util.Uniquify("EventLog Test WIDGET");
|
||||
w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
w.notes = "blah";
|
||||
w.created = DateTime.Now.ToString();
|
||||
w.dollarAmount = 2.22m;
|
||||
w.active = true;
|
||||
w.usertype = 1;
|
||||
|
||||
//*** CREATED
|
||||
ApiResponse r2 = await Util.PostAsync("widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||
Util.ValidateDataReturnResponseOk(r2);
|
||||
long w2Id = r2.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
ApiResponse EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);//only one event so far
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(1);//AyEvent 1 = created
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
//Get current user doing modifications ID
|
||||
long CurrentUserId = EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Value<long>();
|
||||
|
||||
//*** RETRIEVED
|
||||
//Get one
|
||||
ApiResponse r3 = await Util.GetAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateDataReturnResponseOk(r3);
|
||||
r3.ObjectResponse["data"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||
w = r3.ObjectResponse["data"];
|
||||
|
||||
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
//confirm event count, type and sort order (descending by date most recent first)
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(2);
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(2);//AyEvent 2 = retrieved
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
//*** MODIFIED
|
||||
//PUT
|
||||
//update w2id
|
||||
w.name = Util.Uniquify("UPDATED VIA PUT EVENTLOG TEST WIDGET");
|
||||
w.UserId = 1;
|
||||
w.concurrency = r2.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
ApiResponse PUTTestResponse = await Util.PutAsync("widget", await Util.GetTokenAsync("InventoryFull"), w.ToString());
|
||||
Util.ValidateHTTPStatusCode(PUTTestResponse, 200);
|
||||
|
||||
//*** RETRIEVED
|
||||
//check PUT worked
|
||||
ApiResponse checkPUTWorked = await Util.GetAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateNoErrorInResponse(checkPUTWorked);
|
||||
checkPUTWorked.ObjectResponse["data"]["name"].Value<string>().Should().Be(w.name.ToString());
|
||||
uint concurrency = PUTTestResponse.ObjectResponse["data"]["concurrency"].Value<uint>();
|
||||
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(4);
|
||||
//put op is the second item in the list, top item is the recent fetch
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["event"].Value<int>().Should().Be(3);//AyEvent 3 = Modified
|
||||
EventLogResponse.ObjectResponse["data"]["events"][1]["textra"].Should().BeNullOrEmpty();
|
||||
|
||||
|
||||
//Check user log for basic accessibility userlog?UserId=7
|
||||
EventLogResponse = await Util.GetAsync($"event-log/userlog?UserId={CurrentUserId}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().BeGreaterOrEqualTo(4);//just one run of the above will be 4 events plus any others from other tests
|
||||
//Not sure of any easy way to assert the User log is correct other than the count as other tests running concurrently could easily skew this
|
||||
|
||||
|
||||
//DELETE
|
||||
ApiResponse DELETETestResponse = await Util.DeleteAsync("widget/" + w2Id.ToString(), await Util.GetTokenAsync("InventoryFull"));
|
||||
Util.ValidateHTTPStatusCode(DELETETestResponse, 204);
|
||||
|
||||
//All events should be cleared up on deletion with the sole exception of the deleted event
|
||||
EventLogResponse = await Util.GetAsync($"event-log/objectlog?AyaType=2&AyId={w2Id}", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateHTTPStatusCode(EventLogResponse, 200);
|
||||
((JArray)EventLogResponse.ObjectResponse["data"]["events"]).Count.Should().Be(1);
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["date"].Value<DateTime>().Should().BeLessThan(new TimeSpan(1, 0, 0)).Before(DateTime.UtcNow);//should be less than one hour before now
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["userId"].Should().NotBeNull();
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["event"].Value<int>().Should().Be(0);//AyEvent 0 = deleted
|
||||
EventLogResponse.ObjectResponse["data"]["events"][0]["textra"].Value<string>().Should().Be(w.name.ToString());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task UserLogWorks()
|
||||
{
|
||||
//get admin log, sb lots of shit
|
||||
ApiResponse a = await Util.GetAsync($"event-log/userlog?UserId=1&Offset=0&Limit=999", await Util.GetTokenAsync("BizAdminFull"));
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().BeGreaterThan(90);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task EventLogLimitOffSetWorks()
|
||||
{
|
||||
|
||||
var UniqueName = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||
//CREATE
|
||||
dynamic d = new JObject();
|
||||
d.name = UniqueName;
|
||||
|
||||
d.active = true;
|
||||
d.login = UniqueName;
|
||||
d.password = UniqueName;
|
||||
d.roles = 2;//bizadminfull needs widget rights
|
||||
d.userType = 3;//non scheduleable
|
||||
|
||||
//Required by form custom rules
|
||||
d.notes = "notes";
|
||||
d.customFields = Util.UserRequiredCustomFieldsJsonString();
|
||||
|
||||
ApiResponse a = await Util.PostAsync("User", await Util.GetTokenAsync("superuser", "l3tm3in"), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
long UserId = a.ObjectResponse["data"]["id"].Value<long>();
|
||||
|
||||
|
||||
//Loop and make 10 widgets
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
d = new JObject();
|
||||
d.name = Util.Uniquify("EventLogLimitOffSetWorks");
|
||||
d.customFields = Util.WidgetRequiredCustomFieldsJsonString();
|
||||
d.dollarAmount = 1.11m;
|
||||
d.active = true;
|
||||
d.usertype = 1;
|
||||
d.notes = "note here";
|
||||
a = await Util.PostAsync("widget", await Util.GetTokenAsync(UniqueName, UniqueName), d.ToString());
|
||||
Util.ValidateDataReturnResponseOk(a);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=0&Limit=9", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(9);
|
||||
//capture events, then compare to paged ones
|
||||
var eventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
List<string> allEvents = new List<string>(9);
|
||||
foreach (JObject o in eventList)
|
||||
{
|
||||
allEvents.Add(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=0&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
var pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=1&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
a = await Util.GetAsync($"event-log/userlog?UserId={UserId}&Offset=2&Limit=3", await Util.GetTokenAsync("BizAdminFull"));
|
||||
((JArray)a.ObjectResponse["data"]["events"]).Count.Should().Be(3);
|
||||
pageEventList = ((JArray)a.ObjectResponse["data"]["events"]);
|
||||
foreach (JObject o in pageEventList)
|
||||
{
|
||||
allEvents.Should().Contain(o["date"].Value<string>() + o["objectType"].Value<string>()
|
||||
+ o["objectId"].Value<string>() + o["name"].Value<string>() + o["event"].Value<string>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
|
||||
Reference in New Issue
Block a user