@@ -27,6 +27,24 @@ - (void)testCreateAndGetPet {
27
27
}
28
28
if (output){
29
29
XCTAssertNotNil ([output _id ], @" token was nil" );
30
+
31
+ // test category of pet is correct
32
+ XCTAssertEqualObjects (output.category ._id , pet.category ._id );
33
+ XCTAssertEqualObjects (output.category .name , pet.category .name );
34
+
35
+ // test tags of pet is correct
36
+ XCTAssertTrue ([output.tags isKindOfClass: [NSArray class ]]);
37
+ [pet.tags enumerateObjectsUsingBlock: ^(id obj, NSUInteger idx, BOOL *stop) {
38
+ SWGTag *foundTag = [[SWGTag alloc ] init ];
39
+ for (SWGTag *tag in output.tags ) {
40
+ if ([tag _id ] == [obj _id ]) {
41
+ foundTag = tag;
42
+ }
43
+ }
44
+ XCTAssertNotNil (foundTag);
45
+ XCTAssertEqualObjects ([foundTag _id ], [obj _id ]);
46
+ XCTAssertEqualObjects ([foundTag name ], [obj name ]);
47
+ }];
30
48
}
31
49
[expectation fulfill ];
32
50
}];
@@ -221,10 +239,20 @@ - (SWGPet*) createPet {
221
239
SWGPet * pet = [[SWGPet alloc ] init ];
222
240
pet._id = [[NSNumber alloc ] initWithLong: [[NSDate date ] timeIntervalSince1970 ]];
223
241
pet.name = @" monkey" ;
242
+
224
243
SWGCategory * category = [[SWGCategory alloc ] init ];
244
+ category._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
225
245
category.name = @" super-happy" ;
226
-
227
246
pet.category = category;
247
+
248
+ SWGTag *tag1 = [[SWGTag alloc ] init ];
249
+ tag1._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
250
+ tag1.name = @" test tag 1" ;
251
+ SWGTag *tag2 = [[SWGTag alloc ] init ];
252
+ tag2._id = [[NSNumber alloc ] initWithInteger: arc4random_uniform (100000 )];
253
+ tag2.name = @" test tag 2" ;
254
+ pet.tags = (NSArray <SWGTag> *)[[NSArray alloc ] initWithObjects: tag1, tag2, nil ];
255
+
228
256
pet.status = @" available" ;
229
257
230
258
NSArray * photos = [[NSArray alloc ] initWithObjects: @" http://foo.bar.com/3" , @" http://foo.bar.com/4" , nil ];
0 commit comments