Skip to content

Commit 58feda7

Browse files
committed
Updated test case testCreateAndGetPet of objc client.
1 parent 2662167 commit 58feda7

File tree

1 file changed

+29
-1
lines changed
  • samples/client/petstore/objc/PetstoreClient/PetstoreClientTests

1 file changed

+29
-1
lines changed

samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ - (void)testCreateAndGetPet {
2727
}
2828
if(output){
2929
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+
}];
3048
}
3149
[expectation fulfill];
3250
}];
@@ -221,10 +239,20 @@ - (SWGPet*) createPet {
221239
SWGPet * pet = [[SWGPet alloc] init];
222240
pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]];
223241
pet.name = @"monkey";
242+
224243
SWGCategory * category = [[SWGCategory alloc] init];
244+
category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)];
225245
category.name = @"super-happy";
226-
227246
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+
228256
pet.status = @"available";
229257

230258
NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil];

0 commit comments

Comments
 (0)