@@ -258,6 +258,88 @@ - (void)test04FetchAssets {
258258 [self waitForRequest ];
259259}
260260
261+ - (void )testFetchAssetByQuery01 {
262+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By where method" ];
263+ AssetLibrary* assets = [csStack assetLibrary ];
264+ [assets where: @" title" equalTo: @" image1" ];
265+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
266+ if (error) {
267+ XCTFail (@" ~ ERR: %@ , Message = %@ " , error.userInfo , error.description );
268+ } else {
269+ XCTAssert (type == NETWORK, @" Pass" );
270+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
271+ XCTAssert (result.count > 0 , @" Expected results, but got none." );
272+ }
273+ [expectation fulfill ];
274+ }];
275+ [self waitForRequest ];
276+ }
277+
278+ - (void )testFetchAssetsByValidFileSize02 {
279+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By valid file size" ];
280+ AssetLibrary *assets = [csStack assetLibrary ];
281+ [assets where: @" file_size" equalTo: @(53986 )]; // Valid file size
282+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
283+ XCTAssert (type == NETWORK, @" Pass" );
284+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
285+ XCTAssert (result.count > 0 , @" Expected results, but got none." );
286+ [expectation fulfill ];
287+ }];
288+ [self waitForRequest ];
289+ }
290+
291+ - (void )testFetchAssetsByNonExistentFileSize03 {
292+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By non-existent file size" ];
293+ AssetLibrary *assets = [csStack assetLibrary ];
294+ [assets where: @" file_size" equalTo: @(9999999 )]; // Non-existent file size
295+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
296+ XCTAssert (type == NETWORK, @" Pass" );
297+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
298+ XCTAssertEqual (result.count , 0 , @" Expected no results, but got some." );
299+ [expectation fulfill ];
300+ }];
301+ [self waitForRequest ];
302+ }
303+
304+ - (void )testFetchAssetsByNonExistentTitle04 {
305+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By non-existent title" ];
306+ AssetLibrary *assets = [csStack assetLibrary ];
307+ [assets where: @" title" equalTo: @" non-existent-title.png" ]; // Non-existent title
308+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
309+ XCTAssert (type == NETWORK, @" Pass" );
310+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
311+ XCTAssertEqual (result.count , 0 , @" Expected no results, but got some." );
312+ [expectation fulfill ];
313+ }];
314+ [self waitForRequest ];
315+ }
316+
317+ - (void )testFetchAssetsByMultipleConditions05 {
318+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By multiple conditions" ];
319+ AssetLibrary *assets = [csStack assetLibrary ];
320+ [assets where: @" file_size" equalTo: @(6884 )]; // Valid file size
321+ [assets where: @" title" equalTo: @" image4" ]; // Valid title
322+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
323+ XCTAssert (type == NETWORK, @" Pass" );
324+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
325+ XCTAssert (result.count > 0 , @" Expected results, but got none." );
326+ [expectation fulfill ];
327+ }];
328+ [self waitForRequest ];
329+ }
330+
331+ - (void )testFetchAssetsByInvalidFieldName06 {
332+ XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Asset By invalid field name" ];
333+ AssetLibrary *assets = [csStack assetLibrary ];
334+ [assets where: @" invalid_field" equalTo: @" value" ]; // Invalid field name
335+ [assets fetchAll: ^(ResponseType type, NSArray *result, NSError *error) {
336+ XCTAssert (type == NETWORK, @" Pass" );
337+ XCTAssertNil (error, @" Expected no error, but got: %@ " , error.userInfo );
338+ XCTAssertEqual (result.count , 0 , @" Expected no results." );
339+ [expectation fulfill ];
340+ }];
341+ [self waitForRequest ];
342+ }
261343
262344- (void )testGetHeader {
263345 XCTestExpectation *expectation = [self expectationWithDescription: @" Fetch Set Header" ];
0 commit comments