mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #1129 from geekerzp/objc-test
[Objc] Add test cases for sanitizeForSerialization method in objc client
This commit is contained in:
commit
587028efd1
@ -1,7 +1,12 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import <ISO8601/ISO8601.h>
|
||||
#import <SwaggerClient/SWGApiClient.h>
|
||||
#import <SwaggerClient/SWGConfiguration.h>
|
||||
#import <SwaggerClient/SWGQueryParamCollection.h>
|
||||
#import <SwaggerClient/SWGPet.h>
|
||||
#import <SwaggerClient/SWGTag.h>
|
||||
#import <SwaggerClient/SWGCategory.h>
|
||||
|
||||
@interface SWGApiClientTest : XCTestCase
|
||||
|
||||
@ -98,4 +103,65 @@
|
||||
XCTAssertEqualObjects(basicAuthCredentials, [config getBasicAuthToken]);
|
||||
}
|
||||
|
||||
- (void)testSanitizeForSerialization {
|
||||
id result;
|
||||
id data;
|
||||
|
||||
// nil
|
||||
data = nil;
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
|
||||
// NSString
|
||||
data = @"test string";
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
|
||||
// NSNumber
|
||||
data = @1;
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
|
||||
// SWGQueryParamCollection
|
||||
data = [[SWGQueryParamCollection alloc] init];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
|
||||
// NSDate
|
||||
data = [NSDate dateWithISO8601String:@"1997-07-16T19:20:30.45+01:00"];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, [data ISO8601String]);
|
||||
|
||||
data = [NSDate dateWithISO8601String:@"1997-07-16"];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, [data ISO8601String]);
|
||||
|
||||
// model
|
||||
NSDictionary *petDict = @{@"id": @1, @"name": @"monkey",
|
||||
@"category": @{@"id": @1, @"name": @"test category"},
|
||||
@"tags": @[@{@"id": @1, @"name": @"test tag1"},
|
||||
@{@"id": @2, @"name": @"test tag2"}],
|
||||
@"status": @"available",
|
||||
@"photoUrls": @[@"http://foo.bar.com/3", @"http://foo.bar.com/4"]};
|
||||
data = [[SWGPet alloc] initWithDictionary:petDict error:nil];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, petDict);
|
||||
|
||||
// NSArray
|
||||
data = @[@1];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
|
||||
// NSArray of models
|
||||
NSArray *arrayOfPetDict = @[petDict];
|
||||
data = [NSArray arrayWithObject:[[SWGPet alloc] initWithDictionary:petDict error:nil]];
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, arrayOfPetDict);
|
||||
|
||||
// NSDictionary
|
||||
data = @{@"test key": @"test value"};
|
||||
result = [self.apiClient sanitizeForSerialization:data];
|
||||
XCTAssertEqualObjects(result, data);
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user