Adds armorName to Monster entity.

Adds tests for armorName.
This commit is contained in:
2020-09-13 04:15:17 -07:00
parent a6f048cc2d
commit 5aa88932f7
4 changed files with 15 additions and 4 deletions

View File

@@ -21,7 +21,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface Monster : NSManagedObject
@property NSString *armorName;
@property NSString *otherArmorDescription;
@property NSString *hpText;
@property NSString *speed;

View File

@@ -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

View File

@@ -2,6 +2,7 @@
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19G2021" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
<entity name="Monster" representedClassName="Monster" syncable="YES" codeGenerationType="category">
<attribute name="alignment" attributeType="String" defaultValueString=""/>
<attribute name="armorName" optional="YES" attributeType="String" defaultValueString=""/>
<attribute name="charismaScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="constitutionScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="dexterityScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
@@ -14,6 +15,6 @@
<attribute name="wisdomScore" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
</entity>
<elements>
<element name="Monster" positionX="-63" positionY="-18" width="128" height="208"/>
<element name="Monster" positionX="-63" positionY="-18" width="128" height="223"/>
</elements>
</model>

View File

@@ -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