Created
April 9, 2018 05:29
-
-
Save max-potapov/ad2ef7a6df1ddcbabbd27ab36a7fa055 to your computer and use it in GitHub Desktop.
TDD intro playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import Foundation | |
import XCTest | |
let fullname = "John Doe" | |
let age = 42 | |
let me = false | |
typealias JSON = [String: Any] | |
let json: JSON = [ | |
"name": fullname, | |
"age": age | |
] | |
struct Person { | |
var name: String? | |
var age: Int? | |
private(set) var isMe = false | |
init(json: JSON) { | |
// name = json["name"] as? String | |
// age = json["age"] as? Int | |
} | |
} | |
final class PersonTests: XCTestCase { | |
let person = Person(json: json) | |
func testName() { | |
XCTAssertEqual(person.name, fullname) | |
} | |
func testAge() { | |
XCTAssertEqual(person.age, age) | |
} | |
func testMe() { | |
XCTAssertEqual(person.isMe, me) | |
} | |
} | |
PersonTests.defaultTestSuite.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment