From 58feda7c8e075d6f41f003ee86aaf42bfd80b004 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Thu, 4 Jun 2015 16:44:12 +0800 Subject: [PATCH] Updated test case `testCreateAndGetPet` of objc client. --- .../PetstoreClientTests/PetApiTest.m | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m index 6fb2b6e57c2..32625dce467 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m @@ -27,6 +27,24 @@ } if(output){ XCTAssertNotNil([output _id], @"token was nil"); + + // test category of pet is correct + XCTAssertEqualObjects(output.category._id, pet.category._id); + XCTAssertEqualObjects(output.category.name, pet.category.name); + + // test tags of pet is correct + XCTAssertTrue([output.tags isKindOfClass:[NSArray class]]); + [pet.tags enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { + SWGTag *foundTag = [[SWGTag alloc] init]; + for (SWGTag *tag in output.tags) { + if ([tag _id] == [obj _id]) { + foundTag = tag; + } + } + XCTAssertNotNil(foundTag); + XCTAssertEqualObjects([foundTag _id], [obj _id]); + XCTAssertEqualObjects([foundTag name], [obj name]); + }]; } [expectation fulfill]; }]; @@ -221,10 +239,20 @@ SWGPet * pet = [[SWGPet alloc] init]; pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]]; pet.name = @"monkey"; + SWGCategory * category = [[SWGCategory alloc] init]; + category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; category.name = @"super-happy"; - pet.category = category; + + SWGTag *tag1 = [[SWGTag alloc] init]; + tag1._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag1.name = @"test tag 1"; + SWGTag *tag2 = [[SWGTag alloc] init]; + tag2._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag2.name = @"test tag 2"; + pet.tags = (NSArray *)[[NSArray alloc] initWithObjects:tag1, tag2, nil]; + pet.status = @"available"; NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil];