View Tistory135_4.swift
func testCallToiTunesCompletes() {
let url = URL(string: "https://itune.apple.com/search?media=music&entity=song&term=abba")
let promise = expectation(description: "Completion handler invoked")
var statusCode: Int?
var responseError: Error?
let dataTask = sessionUnderTest.dataTask(with: url!) { data, response, error in
statusCode = (response as? HTTPURLResponse)?.statusCode
responseError = error
View Tistory135_3.swift
func testPowerFunction(){
// given
let expectedValue = 9
// when
let testingResult = myInstance.pow(3)
// then
XCTAssertEqual(expectedValue, testingResult, "결과 값이 올바르지 않습니다.")
}
View Tistory135_2.swift
// Project
...
func pow(_ target: Int) -> Int {
return target*target
}
// Test Target
...
func testPowerFunction(){
let expectedValue = 9
View Tistory135_1.swift
class PJT2_SignUpFormTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
View ProtocolGenerics6.swift
typealias MyOwnType<U> = (value: String, target: U)
...
struct CommonLogic<T: GroupProtocol> where T.RawValue == String {
...
var myOwnValue: MyOwnType<T>?
func getMyOwnValue()-> MyOwnType<T>? {
...
}
View ProtocolGenerics5.swift
typealias MyOwnType = (value: String, target: GroupProtocol)
...
struct CommonLogic<T: GroupProtocol> where T.RawValue == String {
...
var myOwnValue: MyOwnType?
func getMyOwnValue()-> MyOwnType? {
...
}
View ProtocolGenerics4.swift
protocol GroupProtocol: RawRepresentable{
var whoIsMyPartner: Self {get}
}
enum AEntity: String, GroupProtocol {
case ..
case ..
...
var whoIsMyPartner: AEntity {
View ProtocolGenerics3.swift
func case(of target: SomeType) -> T? {
...
return T.init(rawValue: something)
}
View ProtocolGenerics2.swift
struct CommonLogic<T: GroupProtocol> where T.RawValue == String {
...
}
View ProtocolGenerics1.swift
protocol GroupProtocol: RawRepresentable{
...
}
enum AEntity: String, GroupProtocol {
case ..
case ..
...
}