Adds name to Monster detail view.

Adds json initializers for Monster.
This commit is contained in:
2020-09-06 17:33:58 -07:00
parent d338d42912
commit 0ff71193d6
4 changed files with 78 additions and 4 deletions

View File

@@ -0,0 +1,59 @@
//
// MonsterTests.m
// MonsterCardsTests
//
// Created by Tom Hicks on 9/5/20.
// Copyright © 2020 Tom Hicks. All rights reserved.
//
#import <XCTest/XCTest.h>
@import OCHamcrest;
@import OCMockito;
#import "Monster.h"
@interface MonsterTests : XCTestCase
@end
@implementation MonsterTests {
Monster *_monster;
NSString *_jsonString;
NSData *_jsonData;
}
- (void)setUp {
_monster = [[Monster alloc] init];
_jsonString = @"{\"name\":\"Acolyte\"}";
_jsonData = [_jsonString dataUsingEncoding:NSUTF8StringEncoding];
}
- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
- (void)testDefaultInitializer {
XCTAssertNotNil(_monster);
XCTAssertEqualObjects(@"", _monster.name);
}
- (void)testInitWithJSONString {
_monster = [[Monster alloc] initWithJSONString:_jsonString];
XCTAssertNotNil(_monster);
XCTAssertEqualObjects(@"Acolyte", _monster.name);
}
- (void)testInitWithJSONData {
_monster = [[Monster alloc] initWithJSONData:_jsonData];
XCTAssertNotNil(_monster);
XCTAssertEqualObjects(@"Acolyte", _monster.name);
}
- (void)testNameGetterAndSetter {
NSString *name = @"Pixie";
_monster.name = name;
XCTAssertEqualObjects(name, _monster.name);
}
@end