Adds meta string to monster cards.
Implements meta method in Monster to return a formatted meta string. Adds size to edit monster. Moves monster copy logic to copyFromMonster in the Monster class. Fixes JSON parsing to set strings to an empty string if they're missing from the json blob. Makes Monster.size default to an empty string instead of null. Cleans up some raw strings to use NSLocalizedString instead.
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
- (void)setUp {
|
||||
_context = nil;
|
||||
_monster = [[Monster alloc] initWithContext:_context];
|
||||
_jsonString = @"{\"name\":\"Acolyte\"}";
|
||||
_jsonString = @"{\"name\":\"Acolyte\",\"size\":\"large\"}";
|
||||
_jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
- (void)testDefaultInitializer {
|
||||
XCTAssertNotNil(_monster);
|
||||
XCTAssertEqualObjects(@"", _monster.name);
|
||||
XCTAssertEqualObjects(@"", _monster.size);
|
||||
}
|
||||
|
||||
- (void)testInitWithJSONString {
|
||||
@@ -43,13 +44,22 @@
|
||||
|
||||
XCTAssertNotNil(_monster);
|
||||
XCTAssertEqualObjects(@"Acolyte", _monster.name);
|
||||
XCTAssertEqualObjects(@"large", _monster.size);
|
||||
}
|
||||
|
||||
- (void)testInitWithEmptyJSONString {
|
||||
_monster = [[Monster alloc] initWithJSONString:@"{}" andContext:_context];
|
||||
|
||||
XCTAssertNotNil(_monster);
|
||||
XCTAssertEqualObjects(@"", _monster.name);
|
||||
XCTAssertEqualObjects(@"", _monster.size);
|
||||
}
|
||||
- (void)testInitWithJSONData {
|
||||
_monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context];
|
||||
|
||||
XCTAssertNotNil(_monster);
|
||||
XCTAssertEqualObjects(@"Acolyte", _monster.name);
|
||||
XCTAssertEqualObjects(@"large", _monster.size);
|
||||
}
|
||||
|
||||
- (void)testNameGetterAndSetter {
|
||||
@@ -58,4 +68,10 @@
|
||||
XCTAssertEqualObjects(name, _monster.name);
|
||||
}
|
||||
|
||||
- (void)testSizeGetterAndSetter {
|
||||
NSString *size = @"huge";
|
||||
_monster.size = size;
|
||||
XCTAssertEqualObjects(size, _monster.size);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user