Last active
October 8, 2015 09:28
-
-
Save up1/645ee7e2b94d17c0fd68 to your computer and use it in GitHub Desktop.
TDD Swift
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
class Employee { | |
private let id: Int | |
private let firstname: String | |
init(id: Int, firstname: String) { | |
self.id = id | |
self.firstname = firstname | |
} | |
} |
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
class Employee { | |
private let id: Int | |
private let firstname: String | |
init(id: Int, firstname: String) { | |
self.id = id | |
self.firstname = firstname | |
} | |
func asDictionary() -> [String: AnyObject] { | |
return [String : AnyObject]() | |
} | |
} |
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
public class Employee { | |
private let id: Int | |
private let firstname: String | |
init(id: Int, firstname: String) { | |
self.id = id | |
self.firstname = firstname | |
} | |
func asDictionary() -> [String: AnyObject] { | |
return [ | |
"id": 1, | |
"firstname": "Somkiat" | |
] | |
} | |
} |
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
public class Employee { | |
private let id: Int | |
private let firstname: String | |
init(id: Int, firstname: String) { | |
self.id = id | |
self.firstname = firstname | |
} | |
func asDictionary() -> [String: AnyObject] { | |
return [ | |
"id": self.id, | |
"firstname": self.firstname | |
] | |
} | |
} |
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
class EmployeeTest: XCTestCase { | |
func testCreateNewEmployee() { | |
let employee = Employee(id: 1, firstname: "Somkiat") | |
} | |
} |
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
class EmployeeTest: XCTestCase { | |
func testCreateNewEmployee() { | |
let employee = Employee(id: 1, firstname: "Somkiat") | |
let dictionary = employee.asDictionary() | |
} | |
} |
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
class EmployeeTest: XCTestCase { | |
func testCreateNewEmployee() { | |
let employee = Employee(id: 1, firstname: "Somkiat") | |
let dictionary = employee.asDictionary() | |
XCTAssertEqual(dictionary["id"] as? Int, 1) | |
XCTAssertEqual(dictionary["firstname"] as? String, "Somkiat") | |
} | |
} |
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
class EmployeeTest: XCTestCase { | |
func testCreateNewEmployee() { | |
let employee = Employee(id: 1, firstname: "Somkiat") | |
let dictionary = employee.asDictionary() | |
XCTAssertEqual(dictionary["id"] as? Int, 1) | |
XCTAssertEqual(dictionary["firstname"] as? String, "Somkiat") | |
} | |
func testCreateNewEmployeeWithId2() { | |
let employee = Employee(id: 2, firstname: "Up1") | |
let dictionary = employee.asDictionary() | |
XCTAssertEqual(dictionary["id"] as? Int, 2) | |
XCTAssertEqual(dictionary["firstname"] as? String, "Up1") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment