Adds strengthScore and strengthModifier to Monster.

Adds tests for strengthScore and strengthModifier.
This commit is contained in:
2020-09-13 03:16:32 -07:00
parent 2fd50a9f68
commit 91a99a5df3
2 changed files with 29 additions and 2 deletions

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\"}";
_jsonString = @"{\"name\":\"Acolyte\",\"size\":\"medium\",\"type\":\"humanoid\",\"tag\":\"any race\",\"alignment\":\"any alignment\",\"strPoints\":8}";
_jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding];
}
@@ -40,6 +40,7 @@
XCTAssertEqualObjects(@"", _monster.type);
XCTAssertEqualObjects(@"", _monster.subtype);
XCTAssertEqualObjects(@"", _monster.alignment);
XCTAssertEqual(0, _monster.strengthScore);
}
- (void)testInitWithJSONString {
@@ -51,6 +52,7 @@
XCTAssertEqualObjects(@"humanoid", _monster.type);
XCTAssertEqualObjects(@"any race", _monster.subtype);
XCTAssertEqualObjects(@"any alignment", _monster.alignment);
XCTAssertEqual(8, _monster.strengthScore);
}
- (void)testInitWithEmptyJSONString {
@@ -62,6 +64,7 @@
XCTAssertEqualObjects(@"", _monster.type);
XCTAssertEqualObjects(@"", _monster.subtype);
XCTAssertEqualObjects(@"", _monster.alignment);
XCTAssertEqual(0, _monster.strengthScore);
}
- (void)testInitWithJSONData {
_monster = [[Monster alloc] initWithJSONData:_jsonData andContext:_context];
@@ -72,6 +75,7 @@
XCTAssertEqualObjects(@"humanoid", _monster.type);
XCTAssertEqualObjects(@"any race", _monster.subtype);
XCTAssertEqualObjects(@"any alignment", _monster.alignment);
XCTAssertEqual(8, _monster.strengthScore);
}
- (void)testNameGetterAndSetter {
@@ -113,6 +117,7 @@
XCTAssertEqualObjects(@"humanoid", _monster.type);
XCTAssertEqualObjects(@"any race", _monster.subtype);
XCTAssertEqualObjects(@"any alignment", _monster.alignment);
XCTAssertEqual(8, _monster.strengthScore);
}
- (void)testMetaWithNoFieldsSet {
@@ -231,4 +236,20 @@
XCTAssertEqual(5, [Monster abilityModifierForScore:20]);
}
- (void)testStrengthScoreGetterAndSetter {
_monster.strengthScore = 11;
XCTAssertEqual(11, _monster.strengthScore);
}
- (void)testStrengthModifier {
_monster.strengthScore = 9;
XCTAssertEqual(-1, _monster.strengthModifier);
_monster.strengthScore = 10;
XCTAssertEqual(0, _monster.strengthModifier);
_monster.strengthScore = 12;
XCTAssertEqual(1, _monster.strengthModifier);
}
@end