diff --git a/MonsterCards/Models/Monster.h b/MonsterCards/Models/Monster.h index 4f6ad6f..d8afc72 100644 --- a/MonsterCards/Models/Monster.h +++ b/MonsterCards/Models/Monster.h @@ -21,7 +21,6 @@ NS_ASSUME_NONNULL_BEGIN @interface Monster : NSManagedObject -@property NSString *armorName; @property NSString *otherArmorDescription; @property NSString *hpText; @property NSString *speed; diff --git a/MonsterCards/Models/Monster.m b/MonsterCards/Models/Monster.m index 9f0a398..69c77e8 100644 --- a/MonsterCards/Models/Monster.m +++ b/MonsterCards/Models/Monster.m @@ -11,7 +11,6 @@ @implementation Monster -@synthesize armorName; @synthesize blindsightDistance; @synthesize burrowSpeed; @synthesize challengeRating; @@ -71,6 +70,7 @@ self.type = [jsonRoot objectForKey:@"type"] ?: @""; self.subtype = [jsonRoot objectForKey:@"tag"] ?: @""; self.alignment = [jsonRoot objectForKey:@"alignment"] ?: @""; + self.armorName = [jsonRoot objectForKey:@"armorName"] ?: @""; tempNumber = [jsonRoot objectForKey:@"strPoints"]; if (tempNumber != nil && [tempNumber isKindOfClass:[NSNumber class]]) { self.strengthScore = tempNumber.intValue; @@ -366,6 +366,7 @@ self.intelligenceScore = monster.intelligenceScore; self.wisdomScore = monster.wisdomScore; self.charismaScore = monster.charismaScore; + self.armorName = monster.armorName; } @end diff --git a/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents b/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents index d6bd62e..d2b1834 100644 --- a/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents +++ b/MonsterCards/MonsterCards.xcdatamodeld/MonsterCards.xcdatamodel/contents @@ -2,6 +2,7 @@ + @@ -14,6 +15,6 @@ - + \ No newline at end of file diff --git a/MonsterCardsTests/Models/MonsterTests.m b/MonsterCardsTests/Models/MonsterTests.m index e84c616..3034547 100644 --- a/MonsterCardsTests/Models/MonsterTests.m +++ b/MonsterCardsTests/Models/MonsterTests.m @@ -25,7 +25,7 @@ - (void)setUp { _context = nil; _monster = [[Monster alloc] initWithContext:_context]; - _jsonString = @"{\"name\":\"Acolyte\",\"size\":\"medium\",\"type\":\"humanoid\",\"tag\":\"any race\",\"alignment\":\"any alignment\",\"strPoints\":8,\"dexPoints\":10,\"conPoints\":12,\"intPoints\":14,\"wisPoints\":16,\"chaPoints\":18}"; + _jsonString = @"{\"name\":\"Acolyte\",\"size\":\"medium\",\"type\":\"humanoid\",\"tag\":\"any race\",\"alignment\":\"any alignment\",\"strPoints\":8,\"dexPoints\":10,\"conPoints\":12,\"intPoints\":14,\"wisPoints\":16,\"chaPoints\":18,\"armorName\":\"none\"}"; _jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding]; } @@ -46,6 +46,7 @@ XCTAssertEqual(0, _monster.intelligenceScore); XCTAssertEqual(0, _monster.wisdomScore); XCTAssertEqual(0, _monster.charismaScore); + XCTAssertEqualObjects(@"", _monster.armorName); } - (void)testInitWithJSONString { @@ -63,6 +64,7 @@ XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(18, _monster.charismaScore); + XCTAssertEqualObjects(@"none", _monster.armorName); } - (void)testInitWithEmptyJSONString { @@ -80,6 +82,7 @@ XCTAssertEqual(0, _monster.intelligenceScore); XCTAssertEqual(0, _monster.wisdomScore); XCTAssertEqual(0, _monster.charismaScore); + XCTAssertEqualObjects(@"", _monster.armorName); } - (void)testInitWithJSONData { _monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context]; @@ -96,6 +99,7 @@ XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(18, _monster.charismaScore); + XCTAssertEqualObjects(@"none", _monster.armorName); } - (void)testNameGetterAndSetter { @@ -143,6 +147,7 @@ XCTAssertEqual(14, _monster.intelligenceScore); XCTAssertEqual(16, _monster.wisdomScore); XCTAssertEqual(18, _monster.charismaScore); + XCTAssertEqualObjects(@"none", _monster.armorName); } - (void)testMetaWithNoFieldsSet { @@ -357,4 +362,9 @@ XCTAssertEqual(1, _monster.charismaModifier); } +- (void)testGetterAndSetterForArmorName { + _monster.armorName = @"dandelion"; + XCTAssertEqualObjects(_monster.armorName, @"dandelion"); +} + @end