Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions LeanCloudTests/BaseTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ class BaseTestCase: XCTestCase {
super.tearDown()
}

func object(_ objectId: LCStringConvertible? = nil) -> LCObject {
let className = "\(type(of: self))"
if let objectId = objectId {
return LCObject(className: className, objectId: objectId)
} else {
return LCObject(className: className)
}
}
}

extension BaseTestCase {
Expand All @@ -67,7 +75,6 @@ extension BaseTestCase {
exp.isInverted = true
wait(for: [exp], timeout: seconds)
}

}

extension BaseTestCase {
Expand All @@ -76,7 +83,6 @@ extension BaseTestCase {
return Bundle(for: type(of: self))
.url(forResource: name, withExtension: ext)!
}

}

extension BaseTestCase {
Expand All @@ -91,8 +97,7 @@ extension BaseTestCase {
self.expecting(
timeout: BaseTestCase.timeout,
expectation: { exp },
testcase: testcase
)
testcase: testcase)
}

func expecting(
Expand All @@ -102,20 +107,18 @@ extension BaseTestCase {
self.expecting(
timeout: BaseTestCase.timeout,
expectation: expectation,
testcase: testcase
)
testcase: testcase)
}

func expecting(
timeout: TimeInterval,
expectation: (() -> XCTestExpectation),
expectation: () -> XCTestExpectation,
testcase: (XCTestExpectation) -> Void)
{
self.multiExpecting(
timeout: timeout,
expectations: { [expectation()] },
testcase: { testcase($0[0]) }
)
testcase: { testcase($0[0]) })
}

func multiExpecting(
Expand All @@ -127,7 +130,6 @@ extension BaseTestCase {
testcase(exps)
wait(for: exps, timeout: timeout)
}

}

extension LCApplication {
Expand Down Expand Up @@ -177,5 +179,4 @@ extension LCApplication {
self.id.md5.lowercased(),
isDirectory: true)
}

}
Loading