diff --git a/ApiResponse.cs b/ApiResponse.cs
index df76a38..ecf351a 100644
--- a/ApiResponse.cs
+++ b/ApiResponse.cs
@@ -1,20 +1,20 @@
-using System.Net.Http;
-using Newtonsoft.Json.Linq;
-
-namespace raven_integration
-{
- public class ApiResponse
- {
- public HttpResponseMessage HttpResponse { get; set; }
- public JObject ObjectResponse { get; set; }
- public string CompactResponse
- {
- get
- {
- return ObjectResponse.ToString(Newtonsoft.Json.Formatting.None);
- }
- }
-
-
- }//eoc
+using System.Net.Http;
+using Newtonsoft.Json.Linq;
+
+namespace raven_integration
+{
+ public class ApiResponse
+ {
+ public HttpResponseMessage HttpResponse { get; set; }
+ public JObject ObjectResponse { get; set; }
+ public string CompactResponse
+ {
+ get
+ {
+ return ObjectResponse.ToString(Newtonsoft.Json.Formatting.None);
+ }
+ }
+
+
+ }//eoc
}//eons
\ No newline at end of file
diff --git a/ApiRoot/ApiRoute.cs b/ApiRoot/ApiRoute.cs
index aa10b65..43fa823 100644
--- a/ApiRoot/ApiRoute.cs
+++ b/ApiRoot/ApiRoute.cs
@@ -1,31 +1,31 @@
-using System;
-using Xunit;
-using Newtonsoft.Json.Linq;
-using FluentAssertions;
-using System.Collections.Generic;
-using System.Collections.Concurrent;
-
-namespace raven_integration
-{
-
- public class ApiRoute
- {
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void ServerApiRootPageShouldFetch()
- {
- ApiTextResponse t = await Util.GetNonApiPageAsync("/api/v8/");
- Util.ValidateHTTPStatusCode(t, 200);
- t.TextResponse.Should().Contain("
AyaNova server");
-
- }
-
- //==================================================
-
- }//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 ApiRoute
+ {
+
+
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task ServerApiRootPageShouldFetch()
+ {
+ ApiTextResponse t = await Util.GetNonApiPageAsync("/api/v8/");
+ Util.ValidateHTTPStatusCode(t, 200);
+ t.TextResponse.Should().Contain("AyaNova server");
+
+ }
+
+ //==================================================
+
+ }//eoc
+}//eons
diff --git a/ApiTextResponse.cs b/ApiTextResponse.cs
index 6cad35a..5b52014 100644
--- a/ApiTextResponse.cs
+++ b/ApiTextResponse.cs
@@ -1,13 +1,13 @@
-using System.Net.Http;
-using Newtonsoft.Json.Linq;
-
-namespace raven_integration
-{
- public class ApiTextResponse
- {
- public HttpResponseMessage HttpResponse {get;set;}
- public string TextResponse {get;set;}
-
-
- }//eoc
+using System.Net.Http;
+using Newtonsoft.Json.Linq;
+
+namespace raven_integration
+{
+ public class ApiTextResponse
+ {
+ public HttpResponseMessage HttpResponse {get;set;}
+ public string TextResponse {get;set;}
+
+
+ }//eoc
}//eons
\ No newline at end of file
diff --git a/Attachments/AttachmentTest.cs b/Attachments/AttachmentTest.cs
index ffbc01e..f6f9900 100644
--- a/Attachments/AttachmentTest.cs
+++ b/Attachments/AttachmentTest.cs
@@ -1,204 +1,204 @@
-using System;
-using Xunit;
-using Newtonsoft.Json.Linq;
-using FluentAssertions;
-using System.Collections.Generic;
-using System.Collections.Concurrent;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.IO;
-
-namespace raven_integration
-{
- //https://stackoverflow.com/questions/17725882/testing-asp-net-web-api-multipart-form-data-file-upload
- public class AttachmentTest
- {
- ///
- /// test attach CRUD
- ///
- [Fact]
- public async void AttachmentUploadDownloadDeleteShouldWork()
- {
-
- //Make a user just for this test so can deal with dl token properly
- var UniqueName = Util.Uniquify("AttachmentUploadDownloadDeleteShouldWork");
- //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 TestUserId=a.ObjectResponse["data"]["id"].Value();
-
- d = new JObject();
- d.login = UniqueName;
- d.password = UniqueName;
- a = await Util.PostAsync("auth", null, d.ToString());
- string downloadToken = a.ObjectResponse["data"]["dlt"].Value();
-
- //////////////////////////////////////////
- //// Upload the files
- MultipartFormDataContent formDataContent = new MultipartFormDataContent();
-
- //Form data like the bizobject type and id
- formDataContent.Add(new StringContent("3"), name: "AttachToObjectType");
- formDataContent.Add(new StringContent(TestUserId.ToString()), name: "AttachToObjectId");
- formDataContent.Add(new StringContent("Test:AttachmentUploadDownloadDeleteShouldWork"), name: "Notes");
- formDataContent.Add(new StringContent("[{\"name\":\"test.zip\",\"lastModified\":1582822079618},{\"name\":\"test.png\",\"lastModified\":1586900220990}]"), name: "FileData");
-
- //fileData in JSON stringify format which contains the actual last modified dates etc
- //"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
- //or if testing non-existant this is probably safe: long.MaxValue
-
-
- StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
- file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
- file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
- file1.Headers.ContentDisposition.FileName = "test.png";
- formDataContent.Add(file1);
- StreamContent file2 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.zip"));
- file2.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
- file2.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
- file2.Headers.ContentDisposition.FileName = "test.zip";
- formDataContent.Add(file2);
-
- //create via inventory full test user as attachments use the role of the object attaching to
- a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("superuser", "l3tm3in"));
-
-
- Util.ValidateDataReturnResponseOk(a);
-
- long lTestPngAttachmentId = a.ObjectResponse["data"][0]["id"].Value();
- long lTestZipAttachmentId = a.ObjectResponse["data"][1]["id"].Value();
-
- //saw negative values on a db issue that I corrected (I think)
- //Keeping these in case it arises again, if it does, see log, it's a db error with async issue of some kind
- lTestPngAttachmentId.Should().BePositive();
- lTestZipAttachmentId.Should().BePositive();
-
- //////////////////////////////////////////
- //// DOWNLOAD: Get the file attachment
-
- //now get the file https://rockfish.ayanova.com/api/rfcaseblob/download/248?t=9O2eDAAlZ0Wknj19SBK2iA
- var dlresponse = await Util.DownloadFileAsync("attachment/Download/" + lTestZipAttachmentId.ToString() + "?t=" + downloadToken, null);
-
- //ensure it's the zip file we expected
- dlresponse.Content.Headers.ContentDisposition.FileName.Should().Be("test.zip");
- dlresponse.Content.Headers.ContentLength.Should().BeGreaterThan(2000);
-
-
- //////////////////////////////////////////
- //// DELETE: Delete the file attachments
- a = await Util.DeleteAsync("attachment/" + lTestPngAttachmentId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("attachment/" + lTestZipAttachmentId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
- Util.ValidateHTTPStatusCode(a, 204);
-
-
- }
-
-
-
- ///
- /// test no rights
- ///
- [Fact]
- public async void NoRightsTest()
- {
-
- MultipartFormDataContent formDataContent = new MultipartFormDataContent();
-
- formDataContent.Add(new StringContent("2"), name: "AttachToObjectType");
- formDataContent.Add(new StringContent("1"), name: "AttachToObjectId");
- formDataContent.Add(new StringContent("Test:AttachmentUploadDownloadDeleteShouldWork"), name: "Notes");
- formDataContent.Add(new StringContent("[{\"name\":\"test.png\",\"lastModified\":1586900220990}]"), name: "FileData");
-
-
- StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
- file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
- file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
- file1.Headers.ContentDisposition.FileName = "test.png";
- formDataContent.Add(file1);
-
- //ERROR CONDITION: BizAdminLimited user should not be able to attach a file to a widget
- ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("BizAdminLimited"));
-
- //2004 unauthorized
- Util.ValidateErrorCodeResponse(a, 2004, 403);
-
- }
-
-
- ///
- /// test not attachable
- ///
- [Fact]
- public async void UnattachableTest()
- {
- MultipartFormDataContent formDataContent = new MultipartFormDataContent();
-
- //Form data bizobject type and id
-
- //HERE IS THE ERROR CONDITION: LICENSE TYPE OBJECT WHICH IS UNATTACHABLE
- formDataContent.Add(new StringContent("5"), name: "AttachToObjectType");
- formDataContent.Add(new StringContent("1"), name: "AttachToObjectId");
-
- StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
- file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
- file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
- file1.Headers.ContentDisposition.FileName = "test.png";
- formDataContent.Add(file1);
- ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("InventoryFull"));
-
- //2203 unattachable object
- Util.ValidateErrorCodeResponse(a, 2203, 400);
-
- }
-
-
- ///
- /// test bad object values
- ///
- [Fact]
- public async void BadObject()
- {
- MultipartFormDataContent formDataContent = new MultipartFormDataContent();
-
- //Form data like the bizobject type and id
- formDataContent.Add(new StringContent("2"), name: "AttachToObjectType");
-
- //HERE IS THE ERROR CONDITION, A NON EXISTENT ID VALUE FOR THE WIDGET
- formDataContent.Add(new StringContent(long.MaxValue.ToString()), name: "AttachToObjectId");//non-existent widget
-
- StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
- file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
- file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
- file1.Headers.ContentDisposition.FileName = "test.png";
- formDataContent.Add(file1);
- ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("InventoryFull"));
-
- //2203 invalid attachment object
- Util.ValidateErrorCodeResponse(a, 2203, 400);
-
- }
-
-
-
-
-
-
- //==================================================
-
- }//eoc
-}//eons
+using System;
+using Xunit;
+using Newtonsoft.Json.Linq;
+using FluentAssertions;
+using System.Collections.Generic;
+using System.Collections.Concurrent;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.IO;
+
+namespace raven_integration
+{
+ //https://stackoverflow.com/questions/17725882/testing-asp-net-web-api-multipart-form-data-file-upload
+ public class AttachmentTest
+ {
+ ///
+ /// test attach CRUD
+ ///
+ [Fact]
+ public async Task AttachmentUploadDownloadDeleteShouldWork()
+ {
+
+ //Make a user just for this test so can deal with dl token properly
+ var UniqueName = Util.Uniquify("AttachmentUploadDownloadDeleteShouldWork");
+ //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 TestUserId=a.ObjectResponse["data"]["id"].Value();
+
+ d = new JObject();
+ d.login = UniqueName;
+ d.password = UniqueName;
+ a = await Util.PostAsync("auth", null, d.ToString());
+ string downloadToken = a.ObjectResponse["data"]["dlt"].Value();
+
+ //////////////////////////////////////////
+ //// Upload the files
+ MultipartFormDataContent formDataContent = new MultipartFormDataContent();
+
+ //Form data like the bizobject type and id
+ formDataContent.Add(new StringContent("3"), name: "AttachToObjectType");
+ formDataContent.Add(new StringContent(TestUserId.ToString()), name: "AttachToObjectId");
+ formDataContent.Add(new StringContent("Test:AttachmentUploadDownloadDeleteShouldWork"), name: "Notes");
+ formDataContent.Add(new StringContent("[{\"name\":\"test.zip\",\"lastModified\":1582822079618},{\"name\":\"test.png\",\"lastModified\":1586900220990}]"), name: "FileData");
+
+ //fileData in JSON stringify format which contains the actual last modified dates etc
+ //"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
+ //or if testing non-existant this is probably safe: long.MaxValue
+
+
+ StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
+ file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
+ file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
+ file1.Headers.ContentDisposition.FileName = "test.png";
+ formDataContent.Add(file1);
+ StreamContent file2 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.zip"));
+ file2.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
+ file2.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
+ file2.Headers.ContentDisposition.FileName = "test.zip";
+ formDataContent.Add(file2);
+
+ //create via inventory full test user as attachments use the role of the object attaching to
+ a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("superuser", "l3tm3in"));
+
+
+ Util.ValidateDataReturnResponseOk(a);
+
+ long lTestPngAttachmentId = a.ObjectResponse["data"][0]["id"].Value();
+ long lTestZipAttachmentId = a.ObjectResponse["data"][1]["id"].Value();
+
+ //saw negative values on a db issue that I corrected (I think)
+ //Keeping these in case it arises again, if it does, see log, it's a db error with async issue of some kind
+ lTestPngAttachmentId.Should().BePositive();
+ lTestZipAttachmentId.Should().BePositive();
+
+ //////////////////////////////////////////
+ //// DOWNLOAD: Get the file attachment
+
+ //now get the file https://rockfish.ayanova.com/api/rfcaseblob/download/248?t=9O2eDAAlZ0Wknj19SBK2iA
+ var dlresponse = await Util.DownloadFileAsync("attachment/Download/" + lTestZipAttachmentId.ToString() + "?t=" + downloadToken, null);
+
+ //ensure it's the zip file we expected
+ dlresponse.Content.Headers.ContentDisposition.FileName.Should().Be("test.zip");
+ dlresponse.Content.Headers.ContentLength.Should().BeGreaterThan(2000);
+
+
+ //////////////////////////////////////////
+ //// DELETE: Delete the file attachments
+ a = await Util.DeleteAsync("attachment/" + lTestPngAttachmentId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
+ Util.ValidateHTTPStatusCode(a, 204);
+
+ a = await Util.DeleteAsync("attachment/" + lTestZipAttachmentId.ToString(), await Util.GetTokenAsync("superuser", "l3tm3in"));
+ Util.ValidateHTTPStatusCode(a, 204);
+
+
+ }
+
+
+
+ ///
+ /// test no rights
+ ///
+ [Fact]
+ public async Task NoRightsTest()
+ {
+
+ MultipartFormDataContent formDataContent = new MultipartFormDataContent();
+
+ formDataContent.Add(new StringContent("2"), name: "AttachToObjectType");
+ formDataContent.Add(new StringContent("1"), name: "AttachToObjectId");
+ formDataContent.Add(new StringContent("Test:AttachmentUploadDownloadDeleteShouldWork"), name: "Notes");
+ formDataContent.Add(new StringContent("[{\"name\":\"test.png\",\"lastModified\":1586900220990}]"), name: "FileData");
+
+
+ StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
+ file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
+ file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
+ file1.Headers.ContentDisposition.FileName = "test.png";
+ formDataContent.Add(file1);
+
+ //ERROR CONDITION: BizAdminLimited user should not be able to attach a file to a widget
+ ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("BizAdminLimited"));
+
+ //2004 unauthorized
+ Util.ValidateErrorCodeResponse(a, 2004, 403);
+
+ }
+
+
+ ///
+ /// test not attachable
+ ///
+ [Fact]
+ public async Task UnattachableTest()
+ {
+ MultipartFormDataContent formDataContent = new MultipartFormDataContent();
+
+ //Form data bizobject type and id
+
+ //HERE IS THE ERROR CONDITION: LICENSE TYPE OBJECT WHICH IS UNATTACHABLE
+ formDataContent.Add(new StringContent("5"), name: "AttachToObjectType");
+ formDataContent.Add(new StringContent("1"), name: "AttachToObjectId");
+
+ StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
+ file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
+ file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
+ file1.Headers.ContentDisposition.FileName = "test.png";
+ formDataContent.Add(file1);
+ ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("InventoryFull"));
+
+ //2203 unattachable object
+ Util.ValidateErrorCodeResponse(a, 2203, 400);
+
+ }
+
+
+ ///
+ /// test bad object values
+ ///
+ [Fact]
+ public async Task BadObject()
+ {
+ MultipartFormDataContent formDataContent = new MultipartFormDataContent();
+
+ //Form data like the bizobject type and id
+ formDataContent.Add(new StringContent("2"), name: "AttachToObjectType");
+
+ //HERE IS THE ERROR CONDITION, A NON EXISTENT ID VALUE FOR THE WIDGET
+ formDataContent.Add(new StringContent(long.MaxValue.ToString()), name: "AttachToObjectId");//non-existent widget
+
+ StreamContent file1 = new StreamContent(File.OpenRead($"{Util.TEST_DATA_FOLDER}\\test.png"));
+ file1.Headers.ContentType = new MediaTypeHeaderValue("image/png");
+ file1.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
+ file1.Headers.ContentDisposition.FileName = "test.png";
+ formDataContent.Add(file1);
+ ApiResponse a = await Util.PostFormDataAsync("attachment", formDataContent, await Util.GetTokenAsync("InventoryFull"));
+
+ //2203 invalid attachment object
+ Util.ValidateErrorCodeResponse(a, 2203, 400);
+
+ }
+
+
+
+
+
+
+ //==================================================
+
+ }//eoc
+}//eons
diff --git a/Authentication/Auth.cs b/Authentication/Auth.cs
index b6e85ef..fe7180f 100644
--- a/Authentication/Auth.cs
+++ b/Authentication/Auth.cs
@@ -1,137 +1,137 @@
-using System;
-using Xunit;
-using Newtonsoft.Json.Linq;
-using FluentAssertions;
-
-namespace raven_integration
-{
-
- public class auth
- {
- ///
- ///
- ///
- [Fact]
- public async void BadLoginShouldNotWork()
- {
- //Expect status code 401 and result:
- // {{
- // "error": {
- // "code": "2003",
- // "message": "Authentication failed"
- // }
- // }}
-
- dynamic d = new JObject();
- d.login = "BOGUS";
- d.password = "ACCOUNT";
- ApiResponse a = await Util.PostAsync("auth", null, d.ToString());
- Util.ValidateErrorCodeResponse(a, 2003, 401);
- }
-
-
-
- //NOTE: These tests are for Debug builds, they should still pass in a release build because none of the creds will work and it checks for 401 only
- //but a true test of these JWT tokens is only in server debug mode
-
- ///
- ///
- ///
- [Fact]
- public async void JWTExpiredTokenShouldFail()
- {
-
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "EXPIRED"));//lowest level test user because there are no limits on this route except to be authenticated
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
- ///
- ///
- ///
- [Fact]
- public async void JWTWrongIssuerShouldFail()
- {
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "WRONG_ISSUER"));//lowest level test user because there are no limits on this route except to be authenticated
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
- ///
- ///
- ///
- [Fact]
- public async void JWTNoAlgorithmShouldFail()
- {
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "NO_ALGORITHM"));
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
- ///
- ///
- ///
- [Fact]
- public async void JWTBadSecretShouldFail()
- {
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "WRONG_SECRET"));
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void JWTTruncatedSignatureShouldFail()
- {
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "TRUNCATED_SIGNATURE"));
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void JWTTransposedSignatureShouldFail()
- {
- ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
- var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
- if (BuildMode == "DEBUG")
- {
- a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "TRANSPOSE_SIGNATURE"));
- Util.ValidateHTTPStatusCode(a, 401);
- }
- }
-
-
-
-
- //==================================================
-
- }//eoc
-}//eons
-
+using System;
+using Xunit;
+using Newtonsoft.Json.Linq;
+using FluentAssertions;
+
+namespace raven_integration
+{
+
+ public class Auth
+ {
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task BadLoginShouldNotWork()
+ {
+ //Expect status code 401 and result:
+ // {{
+ // "error": {
+ // "code": "2003",
+ // "message": "Authentication failed"
+ // }
+ // }}
+
+ dynamic d = new JObject();
+ d.login = "BOGUS";
+ d.password = "ACCOUNT";
+ ApiResponse a = await Util.PostAsync("auth", null, d.ToString());
+ Util.ValidateErrorCodeResponse(a, 2003, 401);
+ }
+
+
+
+ //NOTE: These tests are for Debug builds, they should still pass in a release build because none of the creds will work and it checks for 401 only
+ //but a true test of these JWT tokens is only in server debug mode
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTExpiredTokenShouldFail()
+ {
+
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "EXPIRED"));//lowest level test user because there are no limits on this route except to be authenticated
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTWrongIssuerShouldFail()
+ {
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "WRONG_ISSUER"));//lowest level test user because there are no limits on this route except to be authenticated
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTNoAlgorithmShouldFail()
+ {
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "NO_ALGORITHM"));
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTBadSecretShouldFail()
+ {
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "WRONG_SECRET"));
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTTruncatedSignatureShouldFail()
+ {
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "TRUNCATED_SIGNATURE"));
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+
+ ///
+ ///
+ ///
+ [Fact]
+ public async Task JWTTransposedSignatureShouldFail()
+ {
+ ApiResponse a = await Util.GetAsync("build-mode", await Util.GetTokenAsync("superuser", "l3tm3in"));
+ var BuildMode = a.ObjectResponse["data"]["buildMode"].Value();
+ if (BuildMode == "DEBUG")
+ {
+ a = await Util.GetAsync("translation/list", await Util.GetTokenAsync("INTEGRATION_TEST", "TRANSPOSE_SIGNATURE"));
+ Util.ValidateHTTPStatusCode(a, 401);
+ }
+ }
+
+
+
+
+ //==================================================
+
+ }//eoc
+}//eons
+
diff --git a/DataList/DataListFiltering.cs b/DataList/DataListFiltering.cs
index ad394c6..a37194c 100644
--- a/DataList/DataListFiltering.cs
+++ b/DataList/DataListFiltering.cs
@@ -1,3999 +1,3999 @@
-using System;
-using Xunit;
-using Newtonsoft.Json.Linq;
-using FluentAssertions;
-using System.Collections.Generic;
-using System.Collections.Concurrent;
-
-namespace raven_integration
-{
-
-
- /*
-
- EVERY TYPE, EVERY OP
-
- Using the widget object test all filtering options
- for all data types, all operation types
-
- This is the supertest to always confirm the filtering code is working as expected.
-
-
-BUGBUG: Server takes into account user's time zone offset when filtering lists by date range but here the local test runner just uses the windows system offset instead of the defined offset in the User account at the server
-Fix: Since seeder uses same time zone for all users it generates then can simply fetch one single users' tz offset and use that centerally to calculate a relative now and relative today
-same as the server does but in a central location here for all tests to use.
-
- */
-
- public class DataListFiltering
- {
-
-
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////
- //DATE
- //
-
- #region DATE FILTER TESTS
-
- // public const string TokenYesterday = "{[yesterday]}";
- // public const string TokenToday = "{[today]}";
- // public const string TokenTomorrow = "{[tomorrow]}";
- // public const string TokenLastWeek = "{[lastweek]}";
- // public const string TokenThisWeek = "{[thisweek]}";
- // public const string TokenNextWeek = "{[nextweek]}";
- // public const string TokenLastMonth = "{[lastmonth]}";
- // public const string TokenThisMonth = "{[thismonth]}";
- // public const string TokenNextMonth = "{[nextmonth]}";
- // public const string TokenFourteenDayWindow = "{[14daywindow]}";
- // public const string TokenPast = "{[past]}";
- // public const string TokenFuture = "{[future]}";
- // public const string TokenLastYear = "{[lastyear]}";
- // public const string TokenThisYear = "{[thisyear]}";
- // public const string TokenInTheLast3Months = "{[last3months]}";
- // public const string TokenInTheLast6Months = "{[last6months]}";
- // public const string TokenInTheLastYear = "{[lastcalendaryear]}";
-
- // //More business time frames
-
- // public const string TokenYearToDate = "{[yeartodate]}";
-
- // public const string TokenPast90Days = "{[past90days]}";
- // public const string TokenPast30Days = "{[past30days]}";
- // public const string TokenPast24Hours = "{[past24hours]}";
-
- // //Months THIS year
- // public const string TokenJanuary = "{[january]}";
- // public const string TokenFebruary = "{[february]}";
- // public const string TokenMarch = "{[march]}";
- // public const string TokenApril = "{[april]}";
- // public const string TokenMay = "{[may]}";
- // public const string TokenJune = "{[june]}";
- // public const string TokenJuly = "{[july]}";
- // public const string TokenAugust = "{[august]}";
- // public const string TokenSeptember = "{[september]}";
- // public const string TokenOctober = "{[october]}";
- // public const string TokenNovember = "{[november]}";
- // public const string TokenDecember = "{[december]}";
-
-
- #region DATE REGULAR FILTERS
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpEqualityFilterWorks()
- {
-
- var WidgetNameStart = "DateOpEqualityFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1968, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1968, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1968, 3, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
-
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpEquality;
- // FilterItem.value = new DateTime(1968, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- // dListView.Add(Util.BuildSimpleFilterDataListViewColumn("XXXX", Util.XXXX, XXXX));
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpEquality, new DateTime(1968, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime()));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
-
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
-
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpGreaterThanFilterWorks()
- {
-
- var WidgetNameStart = "DateOpGreaterThanFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1968, 3, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpGreaterThan;
- // FilterItem.value = new DateTime(1970, 3, 12, 9, 0, 0).ToOffsetAdjustedUniversalTime();
- // dListView.Add(Util.BuildSimpleFilterDataListViewColumn("XXXX", Util.XXXX, XXXX));
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpGreaterThan, new DateTime(1970, 3, 12, 9, 0, 0).ToOffsetAdjustedUniversalTime()));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
-
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpGreaterThanOrEqualToFilterWorks()
- {
-
- var WidgetNameStart = "DateOpGreaterThanOrEqualToFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1968, 3, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1968, 3, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
-
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpGreaterThanOrEqualTo;
- // FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- // dListView.Add(Util.BuildSimpleFilterDataListViewColumn("XXXX", Util.XXXX, XXXX));
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpGreaterThanOrEqualTo, new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime()));
-
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
-
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpLessThanFilterWorks()
- {
-
- var WidgetNameStart = "DateOpLessThanFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1970, 4, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpLessThan;
- // FilterItem.value = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpLessThan, new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime()));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpLessThanOrEqualToFilterWorks()
- {
-
- var WidgetNameStart = "DateOpLessThanOrEqualToFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1970, 4, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpLessThanOrEqualTo;
- // FilterItem.value = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpLessThanOrEqualTo, new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime()));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpNotEqualToFilterWorks()
- {
-
- var WidgetNameStart = "DateOpNotEqualToFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(1970, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(1970, 4, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(1970, 4, 10, 11, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpNotEqual;
- // FilterItem.value = new DateTime(1970, 4, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpNotEqual, new DateTime(1970, 4, 10, 10, 0, 0).ToOffsetAdjustedUniversalTime()));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void DateOpBetweenFilterWorks()
- {
-
- var WidgetNameStart = "DateOpBetweenFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = new DateTime(2019, 3, 12, 8, 0, 0).ToOffsetAdjustedUniversalTime();
- w.endDate = new DateTime(2019, 3, 12, 9, 0, 0).ToOffsetAdjustedUniversalTime();
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
-
- 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));
-
- //## INCLUSIVE FILTER
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetstartdate";
- // FilterItem.op = Util.OpGreaterThanOrEqualTo;
- // FilterItem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- // dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetstartdate", Util.OpGreaterThanOrEqualTo, new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime()));
-
-
- // dynamic FilterItem2 = new JObject();
- // FilterItem2.fld = "widgetstartdate";
- // FilterItem2.op = Util.OpLessThanOrEqualTo;
- // FilterItem2.value = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- // dListView.Add(FilterItem2);
-
- //Build multiple condition filter (not handled by util method)
- dynamic d = new JObject();
- d.fld = "widgetstartdate";
-
-
- dynamic filter = new JObject();
- dynamic items = new JArray();
-
- dynamic fitem = new JObject();
- fitem.op = Util.OpGreaterThanOrEqualTo;
- fitem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
- items.Add(fitem);
-
- fitem = new JObject();
- fitem.op = Util.OpLessThanOrEqualTo;
- fitem.value = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
- items.Add(fitem);
-
-
- filter.items = items;
- d.filter = filter;
-
- dListView.Add(d);
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
-
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- }
-
- /*
- RELATIVE TOKEN EXAMPLE:
-
- public const string TokenYesterday = "{[yesterday]}";
- public const string TokenToday = "{[today]}";
- public const string TokenTomorrow = "{[tomorrow]}";
- public const string TokenLastWeek = "{[lastweek]}";
- public const string TokenThisWeek = "{[thisweek]}";
- public const string TokenNextWeek = "{[nextweek]}";
- public const string TokenLastMonth = "{[lastmonth]}";
- public const string TokenThisMonth = "{[thismonth]}";
- public const string TokenNextMonth = "{[nextmonth]}";
- public const string TokenFourteenDayWindow = "{[14daywindow]}";
- public const string TokenPast = "{[past]}";
- public const string TokenFuture = "{[future]}";
- public const string TokenLastYear = "{[lastyear]}";
- public const string TokenThisYear = "{[thisyear]}";
- public const string TokenInTheLast3Months = "{[last3months]}";
- public const string TokenInTheLast6Months = "{[last6months]}";
- public const string TokenInTheLastYear = "{[lastcalendaryear]}";
-
- //More business time frames
-
- public const string TokenYearToDate = "{[yeartodate]}";
-
- public const string TokenPast90Days = "{[past90days]}";
- public const string TokenPast30Days = "{[past30days]}";
- public const string TokenPast24Hours = "{[past24hours]}";
-
- //Months THIS year
- public const string TokenJanuary = "{[january]}";
- public const string TokenFebruary = "{[february]}";
- public const string TokenMarch = "{[march]}";
- public const string TokenApril = "{[april]}";
- public const string TokenMay = "{[may]}";
- public const string TokenJune = "{[june]}";
- public const string TokenJuly = "{[july]}";
- public const string TokenAugust = "{[august]}";
- public const string TokenSeptember = "{[september]}";
- public const string TokenOctober = "{[october]}";
- public const string TokenNovember = "{[november]}";
- public const string TokenDecember = "{[december]}";
-
- ///
- ///
- ///
- [Fact]
- public async void DateTokenYesterdayFilterWorks()
- {
-
- var WidgetNameStart = "DateTokenYesterdayFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.startDate = DateTime.UtcNow.AddDays(-1);
- w.endDate = DateTime.UtcNow.AddHours(1).AddDays(-1);
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.startDate = DateTime.UtcNow;
- w.endDate = DateTime.UtcNow.AddHours(1);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- dynamic d = new JObject();
- d.name = Util.Uniquify(WidgetNameStart);
-
- d["public"] = true;
- d.listKey = "TestWidgetDataList";
-
- 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));
-
- //## INCLUSIVE FILTER
- dynamic FilterItem = new JObject();
- FilterItem.fld = "widgetstartdate";
- FilterItem.op = Util.OpEquality;
- FilterItem.value = TokenYesterday;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("XXXX", Util.XXXX, XXXX));
-
-
-
- a = await Util, await Util.GetTokenAsync("BizAdminFull"), d.ToString());
- Util.ValidateDataReturnResponseOk(a);
-
- long DataFilterId = a.ObjectResponse["data"]["id"].Value();
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
-
- //DELETE DATAFILTER
- a = await Util.DeleteAsync("DataListFilter/" + DataFilterId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
-
-
- */
-
- #endregion DATE REGULAR FILTERS
- //========
-
- #endregion date filter tests
-
-
-
- ///////////////////////////////////////////////////////////////////////////////
- //TEXT
- //
-
- #region STRING FILTER TESTS
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpEqualityFilterWorks()
- {
-
- var TestName = "TextOpEqualityFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "aardvark";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "zebra";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpEquality;
- // DataFilterActive.value = "aardvark";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpEquality, "aardvark"));
-
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
-
-
- ///
- /// Specifically test a string with an apostrophe in it (for inclusive)
- ///
- [Fact]
- public async void TextApostropheOpEqualityFilterWorks()
- {
-
- var TestName = "TextApostropheOpEqualityFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "O'Flaherty's pub";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Outback steak house";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpEquality;
- // DataFilterActive.value = "O'Flaherty's pub";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpEquality, "O'Flaherty's pub"));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
- ///
- /// specifically test a string with an ampersand character in it for inclusive (finding it)
- ///
- [Fact]
- public async void TextAmpersandOpEqualityFilterWorks()
- {
-
- var TestName = "TextAmpersandOpEqualityFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Bill & Ted's excellent adventure";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Strange things are afoot at the Circle-K";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpEquality;
- // DataFilterActive.value = "Bill & Ted's excellent adventure";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpEquality, "Bill & Ted's excellent adventure"));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
-
-
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
-
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
- ///
- /// specifically test a non english unicode string
- ///
- [Fact]
- public async void TextUnicodeOpEqualityFilterWorks()
- {
-
- var TestName = "TextUnicodeOpEqualityFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- var InclusiveTestString = "Ādam Iñtërnâtiônà ližætiøn";
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = InclusiveTestString;
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Adam Internationalization";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpEquality;
- // DataFilterActive.value = InclusiveTestString;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpEquality, InclusiveTestString));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpGreaterThanFilterWorks()
- {
-
- var TestName = "TextOpGreaterThanFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Alabama";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Aardvark";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpGreaterThan;
- // DataFilterActive.value = "Aardvark";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpGreaterThan, "Aardvark"));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpGreaterThanOrEqualToFilterWorks()
- {
-
- var TestName = "TextOpGreaterThanOrEqualToFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Bjorn";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Bing";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpGreaterThanOrEqualTo;
- // DataFilterActive.value = "Bjarn";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpGreaterThanOrEqualTo, "Bjarn"));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpLessThanFilterWorks()
- {
-
- var TestName = "TextOpLessThanFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "California";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Cthulu";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpLessThan;
- // DataFilterActive.value = "Celery";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpLessThan, "Celery"));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpLessThanOrEqualToFilterWorks()
- {
-
- var TestName = "TextOpLessThanOrEqualToFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Donut";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Duvet";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpLessThanOrEqualTo;
- // DataFilterActive.value = "Dusseldorf";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpLessThanOrEqualTo, "Dusseldorf"));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpNotEqualFilterWorks()
- {
-
- var TestName = "TextOpNotEqualFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Egg Salad Sandwich";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Elephant";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpNotEqual;
- // DataFilterActive.value = "Elephant";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpNotEqual, "Elephant"));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpNotContainsFilterWorks()
- {
- var TestName = "TextOpNotContainsFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Gray poupon";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Get shorty";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpNotContains;
- // DataFilterActive.value = "short";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpNotContains, "short"));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpContainsFilterWorks()
- {
- var TestName = "TextOpContainsFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Fast Freddy Freak";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Phineas Freak";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpContains;
- // DataFilterActive.value = "red";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpContains, "red"));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpStartsWithFilterWorks()
- {
- var TestName = "TextOpStartsWithFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Granular";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Gus Grifferson";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpStartsWith;
- // DataFilterActive.value = "Gra";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpStartsWith, "Gra"));
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void TextOpEndsWithFilterWorks()
- {
- var TestName = "TextOpEndsWithFilterWorks";
- var WidgetNameStart = Util.Uniquify(TestName);
-
- List InclusiveWidgetIdList = new List();
- List ExclusiveWidgetIdList = new List();
-
- //CREATE 4 TEST WIDGETS
- //two inclusive and two not inclusive
-
- //first inclusive widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "Bo Horvat";
- w.usertype = 1;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second inclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- InclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //first exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.notes = "Bo Duke";
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
- //second exclusive widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.active = false;
-
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExclusiveWidgetIdList.Add(a.ObjectResponse["data"]["id"].Value());
-
-
- //CREATE LISTVIEW
- 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));
-
- //FILTER
- // dynamic DataFilterActive = new JObject();
- // DataFilterActive.fld = "widgetnotes";
- // DataFilterActive.op = Util.OpEndsWith;
- // DataFilterActive.value = "vat";
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetnotes", Util.OpEndsWith, "vat"));
-
-
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least two records
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(1);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (InclusiveWidgetIdList.Contains(o["i"].Value()))
- InclusiveMatchCount++;
- if (ExclusiveWidgetIdList.Contains(o["i"].Value()))
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().Be(InclusiveWidgetIdList.Count);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- foreach (long l in InclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- foreach (long l in ExclusiveWidgetIdList)
- {
- a = await Util.DeleteAsync("widget/" + l.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
- }
-
- }
-
-
- //======================
-
- #endregion string filter tests
-
-
-
-
- ///////////////////////////////////////////////////////////////////////////////
- //INT
- //
- #region INTEGER TESTS
-
- ///
- ///
- ///
- [Fact]
- public async void IntegerOpEqualityFilterWorks()
- {
-
- var WidgetNameStart = "IntegerDataFilterTest";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.active = true;
- w.usertype = 1;
- w.count = 5;
- w.notes = "blah";
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.count = 3;
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //CREATE LISTVIEW
- 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));
-
- //inclusive test filter
-
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetcount";
- // FilterItem.op = Util.OpEquality;
- // FilterItem.value = 5;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetcount", Util.OpEquality, 5));
-
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- }
-
- ///
- ///
- ///
- [Fact]
- public async void IntegerOpGreaterThanFilterWorks()
- {
-
- var WidgetNameStart = "IntegerOpGreaterThanFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "blah";
- w.active = true;
- w.usertype = 1;
- w.count = 55;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.count = -55;
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
-
- //CREATE LISTVIEW
- 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));
-
- //inclusive test filter
-
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetcount";
- // FilterItem.op = Util.OpGreaterThan;
- // FilterItem.value = 54;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetcount", Util.OpGreaterThan, 54));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- }
-
- ///
- ///
- ///
- [Fact]
- public async void IntegerOpGreaterThanOrEqualToFilterWorks()
- {
-
- var WidgetNameStart = "IntegerOpGreaterThanOrEqualToFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "blah";
- w.active = true;
- w.usertype = 1;
- w.count = 555;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.count = 554;
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
-
- //CREATE LISTVIEW
- 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));
-
- //inclusive test filter
-
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetcount";
- // FilterItem.op = Util.OpGreaterThanOrEqualTo;
- // FilterItem.value = 555;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetcount", Util.OpGreaterThanOrEqualTo, 555));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- }
-
-
-
- ///
- ///
- ///
- [Fact]
- public async void IntegerOpLessThanFilterWorks()
- {
-
- var WidgetNameStart = "IntegerOpLessThanFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "blah";
- w.active = true;
- w.usertype = 1;
- w.count = -5555;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.count = 5555;
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
-
- //CREATE LISTVIEW
- 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));
-
- //inclusive test filter
-
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetcount";
- // FilterItem.op = Util.OpLessThan;
- // FilterItem.value = 5555;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetcount", Util.OpLessThan, 5555));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value())
- InclusiveMatchCount++;
- if (ExcludedWidgetId == o["i"].Value())
- ExclusiveMatchCount++;
- }
-
- InclusiveMatchCount.Should().BeGreaterOrEqualTo(1);
- ExclusiveMatchCount.Should().Be(0);
-
- //DELETE WIDGETS
- a = await Util.DeleteAsync("widget/" + IncludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- a = await Util.DeleteAsync("widget/" + ExcludedWidgetId.ToString(), await Util.GetTokenAsync("BizAdminFull"));
- Util.ValidateHTTPStatusCode(a, 204);
-
- }
-
-
- ///
- ///
- ///
- [Fact]
- public async void IntegerOpLessThanOrEqualToFilterWorks()
- {
-
- var WidgetNameStart = "IntegerOpLessThanOrEqualToFilterWorks";
-
- long IncludedWidgetId = 0;
- long ExcludedWidgetId = 0;
-
- //CREATE TEST WIDGETS
-
- //included widget
- dynamic w = new JObject();
- w.name = Util.Uniquify(WidgetNameStart);
- w.customFields = Util.WidgetRequiredCustomFieldsJsonString();
- w.notes = "blah";
- w.active = true;
- w.usertype = 1;
- w.count = -444;
-
- ApiResponse a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- IncludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
- //Excluded widget
- w.name = Util.Uniquify(WidgetNameStart);
- w.count = -443;
- a = await Util.PostAsync("widget", await Util.GetTokenAsync("superuser", "l3tm3in"), w.ToString());
- Util.ValidateDataReturnResponseOk(a);
- ExcludedWidgetId = a.ObjectResponse["data"]["id"].Value();
-
-
- //CREATE LISTVIEW
- 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));
-
- //inclusive test filter
-
- // dynamic FilterItem = new JObject();
- // FilterItem.fld = "widgetcount";
- // FilterItem.op = Util.OpLessThanOrEqualTo;
- // FilterItem.value = -444;
- dListView.Add(Util.BuildSimpleFilterDataListViewColumn("widgetcount", Util.OpLessThanOrEqualTo, -444));
- //FETCH DATALIST
- a = await Util.PostAsync($"data-list", await Util.GetTokenAsync("superuser", "l3tm3in"), Util.BuildDataListRequestEx(dListView));
- Util.ValidateDataReturnResponseOk(a);
- Util.ValidateHTTPStatusCode(a, 200);
-
- //assert contains at least this test record
- ((JArray)a.ObjectResponse["data"]).Count.Should().BeGreaterThan(0);
- var v = ((JArray)a.ObjectResponse["data"]);
- List IDInResultList = new List();
- int InclusiveMatchCount = 0;
- int ExclusiveMatchCount = 0;
- foreach (JArray ja in v)
- {
- JObject o = ja[0] as JObject;
- if (IncludedWidgetId == o["i"].Value