Last active
August 29, 2015 14:27
-
-
Save minutetominute/d9bb9af7109be1ae17c5 to your computer and use it in GitHub Desktop.
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
// | |
// FriendsViewController.swift | |
// MyPoject | |
import Foundation | |
import UIKit | |
import MapKit | |
public class FriendsViewController: UIViewController { | |
public func include(array: [User], userId: String) -> Bool { | |
for item in array { | |
if item.userId == userId { | |
return true | |
} | |
} | |
return false | |
} | |
} |
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
// FriendsViewControllerTest.swift | |
// MyProject | |
import UIKit | |
import XCTest | |
import MyProject | |
class FriendsViewControllerTest: XCTestCase { | |
var viewController: FriendsViewController! | |
override func setUp() { | |
super.setUp() | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
self.viewController = FriendsViewController() | |
self.viewController.loadView() | |
} | |
override func tearDown() { | |
// Put teardown code here. This method is called after the invocation of each test method in the class. | |
super.tearDown() | |
} | |
func mockUsers() -> [User]{ | |
var users = [User(userId: "1", username: "soupguy", gender: 0, name: "Bob"), | |
User(userId: "2", username: "breadeater", gender: 1, name: "Alice"), | |
User(userId: "3", username: "lawnmowersrule", gender: 0, name: "Alex")] | |
return users | |
} | |
func testInclude() { | |
var users = mockUsers() | |
XCTAssert(self.viewController.include(users, userId: "2"), "Pass") | |
} | |
} |
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
// | |
// User.swift | |
// MyProject | |
// | |
import Foundation | |
public class User { | |
var userId: String | |
var username: String | |
var name: String | |
var gender: Int | |
public init(userId: String, username: String, gender: Int, name: String) { | |
self.userId = userId | |
self.username = username | |
self.gender = gender | |
self.name = name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment