forked from jsonmodel/jsonmodel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* auto-ignore readonly properties via property attributes (speed gain) * unit tests for auto-ignored properties
- Loading branch information
Showing
5 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// | ||
// SpecialPropertiesTests.m | ||
// JSONModelDemo_iOS | ||
// | ||
// Created by Marin Todorov on 4/18/14. | ||
// Copyright (c) 2014 Underplot ltd. All rights reserved. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
#import "JSONModel.h" | ||
|
||
#pragma mark - model with block property | ||
@interface BModel: JSONModel | ||
@property (assign, nonatomic) int id; | ||
@property (nonatomic, copy) void(^userLocationCompleted)(); | ||
@end | ||
|
||
@implementation BModel | ||
@end | ||
|
||
#pragma mark - model with read-only properties | ||
@interface RModel: JSONModel | ||
@property (assign, nonatomic) int id; | ||
@property (assign, nonatomic, readonly) int rId; | ||
@property (strong, nonatomic, readonly) NSNumber* nId; | ||
@end | ||
|
||
@implementation RModel | ||
@end | ||
|
||
#pragma mark - test suite | ||
|
||
@interface SpecialPropertiesTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation SpecialPropertiesTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
- (void)tearDown | ||
{ | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
[super tearDown]; | ||
} | ||
|
||
//test autoignoring block properties | ||
- (void)testBlocks | ||
{ | ||
NSString* json = @"{\"id\":1}"; | ||
BModel* bm = [[BModel alloc] initWithString:json error:nil]; | ||
XCTAssertNotNil(bm, @"model failed to crate"); | ||
} | ||
|
||
//test autoignoring read-only properties | ||
- (void)testReadOnly | ||
{ | ||
NSString* json = @"{\"id\":1}"; | ||
RModel* rm = [[RModel alloc] initWithString:json error:nil]; | ||
XCTAssertNotNil(rm, @"model failed to crate"); | ||
} | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters