Skip to content

Commit 1fca457

Browse files
committed
update tests
1 parent 2a8dd10 commit 1fca457

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

tests/Unity2021Test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testHTTPSuccess(): void
4040
...Base::COOKIE_RESPONSES,
4141
...Base::QUERY_HELPER_RESPONSES,
4242
...Base::PERMISSION_HELPER_RESPONSES,
43-
...Base::ID_HELPER_RESPONSES
43+
...Base::ID_HELPER_RESPONSES,
44+
...Base::OPERATOR_HELPER_RESPONSES
4445
];
4546
}

tests/languages/unity/Tests.cs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,23 +211,50 @@ private async Task RunAsyncTest()
211211
Debug.Log(Query.Select(new List<string> { "name", "age" }));
212212
Debug.Log(Query.OrderAsc("title"));
213213
Debug.Log(Query.OrderDesc("title"));
214+
Debug.Log(Query.OrderRandom());
214215
Debug.Log(Query.CursorAfter("my_movie_id"));
215216
Debug.Log(Query.CursorBefore("my_movie_id"));
216217
Debug.Log(Query.Limit(50));
217218
Debug.Log(Query.Offset(20));
218219
Debug.Log(Query.Contains("title", "Spider"));
219220
Debug.Log(Query.Contains("labels", "first"));
220221

221-
// New query methods
222+
// New query methods
222223
Debug.Log(Query.NotContains("title", "Spider"));
223224
Debug.Log(Query.NotSearch("name", "john"));
224225
Debug.Log(Query.NotBetween("age", 50, 100));
225226
Debug.Log(Query.NotStartsWith("name", "Ann"));
226227
Debug.Log(Query.NotEndsWith("name", "nne"));
227228
Debug.Log(Query.CreatedBefore("2023-01-01"));
228229
Debug.Log(Query.CreatedAfter("2023-01-01"));
230+
Debug.Log(Query.CreatedBetween("2023-01-01", "2023-12-31"));
229231
Debug.Log(Query.UpdatedBefore("2023-01-01"));
230232
Debug.Log(Query.UpdatedAfter("2023-01-01"));
233+
Debug.Log(Query.UpdatedBetween("2023-01-01", "2023-12-31"));
234+
235+
// Spatial Distance query tests
236+
Debug.Log(Query.DistanceEqual("location", new List<object> { new List<object> { 40.7128, -74 }, new List<object> { 40.7128, -74 } }, 1000));
237+
Debug.Log(Query.DistanceEqual("location", new List<object> { 40.7128, -74 }, 1000, true));
238+
Debug.Log(Query.DistanceNotEqual("location", new List<object> { 40.7128, -74 }, 1000));
239+
Debug.Log(Query.DistanceNotEqual("location", new List<object> { 40.7128, -74 }, 1000, true));
240+
Debug.Log(Query.DistanceGreaterThan("location", new List<object> { 40.7128, -74 }, 1000));
241+
Debug.Log(Query.DistanceGreaterThan("location", new List<object> { 40.7128, -74 }, 1000, true));
242+
Debug.Log(Query.DistanceLessThan("location", new List<object> { 40.7128, -74 }, 1000));
243+
Debug.Log(Query.DistanceLessThan("location", new List<object> { 40.7128, -74 }, 1000, true));
244+
245+
// Spatial query tests
246+
Debug.Log(Query.Intersects("location", new List<object> { 40.7128, -74 }));
247+
Debug.Log(Query.NotIntersects("location", new List<object> { 40.7128, -74 }));
248+
Debug.Log(Query.Crosses("location", new List<object> { 40.7128, -74 }));
249+
Debug.Log(Query.NotCrosses("location", new List<object> { 40.7128, -74 }));
250+
Debug.Log(Query.Overlaps("location", new List<object> { 40.7128, -74 }));
251+
Debug.Log(Query.NotOverlaps("location", new List<object> { 40.7128, -74 }));
252+
Debug.Log(Query.Touches("location", new List<object> { 40.7128, -74 }));
253+
Debug.Log(Query.NotTouches("location", new List<object> { 40.7128, -74 }));
254+
Debug.Log(Query.Contains("location", new List<object> { new List<object> { 40.7128, -74 }, new List<object> { 40.7128, -74 } }));
255+
Debug.Log(Query.NotContains("location", new List<object> { new List<object> { 40.7128, -74 }, new List<object> { 40.7128, -74 } }));
256+
Debug.Log(Query.Equal("location", new List<object> { new List<object> { 40.7128, -74 }, new List<object> { 40.7128, -74 } }));
257+
Debug.Log(Query.NotEqual("location", new List<object> { new List<object> { 40.7128, -74 }, new List<object> { 40.7128, -74 } }));
231258

232259
Debug.Log(Query.Or(new List<string> { Query.Equal("released", true), Query.LessThan("releasedYear", 1990) }));
233260
Debug.Log(Query.And(new List<string> { Query.Equal("released", false), Query.GreaterThan("releasedYear", 2015) }));
@@ -248,6 +275,33 @@ private async Task RunAsyncTest()
248275
Debug.Log(ID.Unique());
249276
Debug.Log(ID.Custom("custom_id"));
250277

278+
// Operator helper tests
279+
Debug.Log(Operator.Increment(1));
280+
Debug.Log(Operator.Increment(5, 100));
281+
Debug.Log(Operator.Decrement(1));
282+
Debug.Log(Operator.Decrement(3, 0));
283+
Debug.Log(Operator.Multiply(2));
284+
Debug.Log(Operator.Multiply(3, 1000));
285+
Debug.Log(Operator.Divide(2));
286+
Debug.Log(Operator.Divide(4, 1));
287+
Debug.Log(Operator.Modulo(5));
288+
Debug.Log(Operator.Power(2));
289+
Debug.Log(Operator.Power(3, 100));
290+
Debug.Log(Operator.ArrayAppend(new List<object> { "item1", "item2" }));
291+
Debug.Log(Operator.ArrayPrepend(new List<object> { "first", "second" }));
292+
Debug.Log(Operator.ArrayInsert(0, "newItem"));
293+
Debug.Log(Operator.ArrayRemove("oldItem"));
294+
Debug.Log(Operator.ArrayUnique());
295+
Debug.Log(Operator.ArrayIntersect(new List<object> { "a", "b", "c" }));
296+
Debug.Log(Operator.ArrayDiff(new List<object> { "x", "y" }));
297+
Debug.Log(Operator.ArrayFilter(Condition.Equal, "test"));
298+
Debug.Log(Operator.StringConcat("suffix"));
299+
Debug.Log(Operator.StringReplace("old", "new"));
300+
Debug.Log(Operator.Toggle());
301+
Debug.Log(Operator.DateAddDays(7));
302+
Debug.Log(Operator.DateSubDays(3));
303+
Debug.Log(Operator.DateSetNow());
304+
251305
mock = await general.Headers();
252306
Debug.Log(mock.Result);
253307

0 commit comments

Comments
 (0)