Skip to content

Commit 0b5d7e1

Browse files
committed
Objects filtering: Unit tests
1 parent 8774762 commit 0b5d7e1

File tree

2 files changed

+71
-14
lines changed

2 files changed

+71
-14
lines changed

PubNubUnity/Assets/PubNub/Editor/ObjectsTest.cs

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,17 @@ public void TestObjectsGetUsersRequestQueryParam64 ()
10191019
TestObjectsGetUsersCommon (true, true, true, 0, "", "", false);
10201020
}
10211021

1022-
10231022
public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1023+
TestObjectsGetUsersCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1024+
}
1025+
1026+
[Test]
1027+
public void TestObjectsGetUsersRequestWithFilterQueryParam64 ()
1028+
{
1029+
TestObjectsGetUsersCommon (true, true, true, 0, "", "", false, true);
1030+
}
1031+
1032+
public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
10241033
string uuid = "customuuid";
10251034

10261035
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1033,6 +1042,9 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10331042
}
10341043

10351044
string filter = "";
1045+
if(withFilter){
1046+
filter = "name like 'abc - / s*'";
1047+
}
10361048

10371049
PNConfiguration pnConfiguration = new PNConfiguration ();
10381050
pnConfiguration.Origin = EditorCommon.Origin;
@@ -1057,7 +1069,7 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10571069
Uri uri = BuildRequests.BuildObjectsGetUsersRequest (limit, start, end, count, incl, pnUnity, queryParams, filter);
10581070

10591071
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1060-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1072+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users?uuid={3}{7}{10}{11}{4}{8}{9}&pnsdk={5}{6}",
10611073
ssl?"s":"",
10621074
pnConfiguration.Origin,
10631075
EditorCommon.SubscribeKey,
@@ -1068,7 +1080,8 @@ public void TestObjectsGetUsersCommon(bool ssl, bool sendQueryParams, bool withI
10681080
(string.IsNullOrEmpty(incl))?"":string.Format("&include={0}",incl),
10691081
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
10701082
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
1071-
(count) ? "&count=1" : "&count=0"
1083+
(count) ? "&count=1" : "&count=0",
1084+
(withFilter)?"&filter=name%20like%20%27abc%20-%20%2F%20s%2A%27":""
10721085
);
10731086

10741087
string received = uri.OriginalString;
@@ -1459,8 +1472,17 @@ public void TestObjectsGetSpacesRequestQueryParam64 ()
14591472
TestObjectsGetSpacesCommon (true, true, true, 0, "", "", false);
14601473
}
14611474

1462-
1475+
[Test]
1476+
public void TestObjectsGetSpacesRequestWithFilterQueryParam64 ()
1477+
{
1478+
TestObjectsGetSpacesCommon (true, true, true, 0, "", "", false, true);
1479+
}
1480+
14631481
public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1482+
TestObjectsGetSpacesCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1483+
}
1484+
1485+
public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
14641486
string uuid = "customuuid";
14651487

14661488
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1493,11 +1515,15 @@ public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool with
14931515
}
14941516

14951517
string filter = "";
1518+
if(withFilter){
1519+
filter = "name == 'abc - / s*'";
1520+
}
1521+
14961522

14971523
Uri uri = BuildRequests.BuildObjectsGetSpacesRequest (limit, start, end, count, incl, pnUnity, queryParams, filter);
14981524

14991525
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1500-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1526+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces?uuid={3}{7}{10}{11}{4}{8}{9}&pnsdk={5}{6}",
15011527
ssl?"s":"",
15021528
pnConfiguration.Origin,
15031529
EditorCommon.SubscribeKey,
@@ -1508,7 +1534,8 @@ public void TestObjectsGetSpacesCommon(bool ssl, bool sendQueryParams, bool with
15081534
(string.IsNullOrEmpty(incl))?"":string.Format("&include={0}",incl),
15091535
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
15101536
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
1511-
(count) ? "&count=1" : "&count=0"
1537+
(count) ? "&count=1" : "&count=0",
1538+
(withFilter)?"&filter=name%20%3D%3D%20%27abc%20-%20%2F%20s%2A%27":""
15121539
);
15131540

15141541
string received = uri.OriginalString;
@@ -1901,6 +1928,17 @@ public void TestObjectsGetMembersRequestQueryParam64 ()
19011928

19021929

19031930
public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
1931+
TestObjectsGetMembersCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
1932+
}
1933+
1934+
[Test]
1935+
public void TestObjectsGetMembersRequestWithFilterQueryParam64 ()
1936+
{
1937+
TestObjectsGetMembersCommon (true, true, true, 0, "", "", false, true);
1938+
}
1939+
1940+
1941+
public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
19041942
string uuid = "customuuid";
19051943

19061944
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -1934,11 +1972,14 @@ public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool wit
19341972
string ch = "ch";
19351973

19361974
string filter = "";
1975+
if(withFilter){
1976+
filter = "name == 'abc - / s'*";
1977+
}
19371978

19381979
Uri uri = BuildRequests.BuildObjectsGetMembersRequest (ch, limit, start, end, count, incl, pnUnity, queryParams, filter);
19391980

19401981
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
1941-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces/{11}/users?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
1982+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/spaces/{11}/users?uuid={3}{7}{10}{12}{4}{8}{9}&pnsdk={5}{6}",
19421983
ssl?"s":"",
19431984
pnConfiguration.Origin,
19441985
EditorCommon.SubscribeKey,
@@ -1950,7 +1991,8 @@ public void TestObjectsGetMembersCommon(bool ssl, bool sendQueryParams, bool wit
19501991
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
19511992
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
19521993
(count) ? "&count=1" : "&count=0",
1953-
ch
1994+
ch,
1995+
(withFilter)?"&filter=name%20%3D%3D%20%27abc%20-%20%2F%20s%27%2A":""
19541996
);
19551997

19561998
string received = uri.OriginalString;
@@ -2340,9 +2382,19 @@ public void TestObjectsGetMembershipsRequestQueryParam64 ()
23402382
{
23412383
TestObjectsGetMembershipsCommon (true, true, true, 0, "", "", false);
23422384
}
2343-
23442385

2345-
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
2386+
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count){
2387+
TestObjectsGetMembershipsCommon(ssl, sendQueryParams, withIncl, limit, start, end, count, false);
2388+
}
2389+
2390+
2391+
[Test]
2392+
public void TestObjectsGetMembershipsRequestWithFilterQueryParam64 ()
2393+
{
2394+
TestObjectsGetMembershipsCommon (true, true, true, 0, "", "", false, true);
2395+
}
2396+
2397+
public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool withIncl, int limit, string start, string end, bool count, bool withFilter){
23462398
string uuid = "customuuid";
23472399

23482400
Dictionary<string,string> queryParams = new Dictionary<string, string>();
@@ -2374,12 +2426,16 @@ public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool
23742426
incl = "";
23752427
}
23762428
string ch = "ch";
2377-
string filter = "";
2429+
2430+
string filter = "name == 's1236 9'";
2431+
if(!withFilter){
2432+
filter = "";
2433+
}
23782434

23792435
Uri uri = BuildRequests.BuildObjectsGetMembershipsRequest (ch, limit, start, end, count, incl, pnUnity, queryParams, filter);
23802436

23812437
//https://ps.pndsn.com/v1/objects/demo/spaces/UnityUnitTests_86?uuid=customuuid&pnsdk=PubNub-CSharp-UnityOSX%2F4.3.0
2382-
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users/{11}/spaces?uuid={3}{7}{10}{4}{8}{9}&pnsdk={5}{6}",
2438+
string expected = string.Format ("http{0}://{1}/v1/objects/{2}/users/{11}/spaces?uuid={3}{7}{10}{12}{4}{8}{9}&pnsdk={5}{6}",
23832439
ssl?"s":"",
23842440
pnConfiguration.Origin,
23852441
EditorCommon.SubscribeKey,
@@ -2391,7 +2447,8 @@ public void TestObjectsGetMembershipsCommon(bool ssl, bool sendQueryParams, bool
23912447
(string.IsNullOrEmpty(start))?"":string.Format("&start={0}",start),
23922448
(string.IsNullOrEmpty(end))?"":string.Format("&end={0}",end),
23932449
(count) ? "&count=1" : "&count=0",
2394-
ch
2450+
ch,
2451+
(withFilter)?"&filter=name%20%3D%3D%20%27s1236%209%27":""
23952452
);
23962453

23972454
string received = uri.OriginalString;

PubNubUnity/Assets/PubNub/PlayModeTests/PlayModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ public IEnumerator TestMembersAndMemberships() {
18981898
yield return new WaitForSeconds (PlayModeCommon.WaitTimeBetweenCalls4);
18991899
Assert.True(tresult, "ManageMemberships Update didn't return");
19001900

1901-
string filterMembers = string.Format("user.name == '{0}'", name);
1901+
string filterMembers = string.Format("user.name == '{0}'", name2);
19021902

19031903
//Get members with Filter
19041904
tresult = false;

0 commit comments

Comments
 (0)