@@ -37,6 +37,24 @@ - (void)testCreateAndGetPet {
37
37
}
38
38
if (output){
39
39
XCTAssertNotNil ([output _id ], @" token was nil" );
40
+
41
+ // test category of pet is correct
42
+ XCTAssertEqualObjects (output.category ._id , pet.category ._id );
43
+ XCTAssertEqualObjects (output.category .name , pet.category .name );
44
+
45
+ // test tags of pet is correct
46
+ XCTAssertTrue ([output.tags isKindOfClass: [NSArray class ]]);
47
+ [pet.tags enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
48
+ SWGTag *foundTag = [[SWGTag alloc ] init ];
49
+ for (SWGTag *tag in output.tags ) {
50
+ if ([tag _id ] == [obj _id ]) {
51
+ foundTag = tag;
52
+ }
53
+ }
54
+ XCTAssertNotNil (foundTag);
55
+ XCTAssertEqualObjects ([foundTag _id ], [obj _id ]);
56
+ XCTAssertEqualObjects ([foundTag name ], [obj name ]);
57
+ }];
40
58
}
41
59
[expectation fulfill ];
42
60
}];
@@ -231,10 +249,20 @@ - (SWGPet*) createPet {
231
249
SWGPet * pet = [[SWGPet alloc ] init ];
232
250
pet._id = [[NSNumber alloc ] initWithLong: [[NSDate date ] timeIntervalSince1970 ]];
233
251
pet.name = @" monkey" ;
252
+
234
253
SWGCategory * category = [[SWGCategory alloc ] init ];
254
+ category._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
235
255
category.name = @" super-happy" ;
236
-
237
256
pet.category = category;
257
+
258
+ SWGTag *tag1 = [[SWGTag alloc ] init ];
259
+ tag1._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
260
+ tag1.name = @" test tag 1" ;
261
+ SWGTag *tag2 = [[SWGTag alloc ] init ];
262
+ tag2._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
263
+ tag2.name = @" test tag 2" ;
264
+ pet.tags = (NSArray <SWGTag> *)[[NSArray alloc ] initWithObjects: tag1, tag2, nil ];
265
+
238
266
pet.status = @" available" ;
239
267
240
268
NSArray * photos = [[NSArray alloc ] initWithObjects: @" http://foo.bar.com/3" , @" http://foo.bar.com/4" , nil ];
0 commit comments