WIP: broken generics

This commit is contained in:
John Estropia
2016-09-06 20:16:46 +09:00
parent b502895d63
commit 82de482191
95 changed files with 610 additions and 677 deletions

View File

@@ -37,11 +37,11 @@ class BaseTestCase: XCTestCase {
@nonobjc
@discardableResult
func prepareStack<T>(configurations: [String?] = [nil], _ closure: @noescape (dataStack: DataStack) -> T) -> T {
func prepareStack<T>(configurations: [String?] = [nil], _ closure: (_ dataStack: DataStack) -> T) -> T {
let stack = DataStack(
modelName: "Model",
bundle: Bundle(for: self.dynamicType)
bundle: Bundle(for: type(of: self))
)
do {
@@ -49,9 +49,9 @@ class BaseTestCase: XCTestCase {
try stack.addStorageAndWait(
SQLiteStore(
fileURL: try SQLiteStore.defaultRootDirectory
fileURL: SQLiteStore.defaultRootDirectory
.appendingPathComponent(UUID().uuidString)
.appendingPathComponent("\(self.dynamicType)_\(($0 ?? "-null-")).sqlite"),
.appendingPathComponent("\(type(of: self))_\(($0 ?? "-null-")).sqlite"),
configuration: $0,
localStorageOptions: .recreateStoreOnModelMismatch
)
@@ -62,11 +62,11 @@ class BaseTestCase: XCTestCase {
XCTFail(error.coreStoreDumpString)
}
return closure(dataStack: stack)
return closure(stack)
}
@nonobjc
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: @noescape () -> T) -> T {
func expectLogger<T>(_ expectations: [TestLogger.Expectation], closure: () -> T) -> T {
CoreStore.logger = TestLogger(self.prepareLoggerExpectations(expectations))
defer {
@@ -89,7 +89,7 @@ class BaseTestCase: XCTestCase {
var testExpectations: [TestLogger.Expectation: XCTestExpectation] = [:]
for expectation in expectations {
testExpectations[expectation] = self.expectation(withDescription: "Logger Expectation: \(expectation)")
testExpectations[expectation] = self.expectation(description: "Logger Expectation: \(expectation)")
}
return testExpectations
}
@@ -97,13 +97,13 @@ class BaseTestCase: XCTestCase {
@nonobjc
func checkExpectationsImmediately() {
self.waitForExpectations(withTimeout: 0, handler: nil)
self.waitForExpectations(timeout: 0, handler: nil)
}
@nonobjc
func waitAndCheckExpectations() {
self.waitForExpectations(withTimeout: 10, handler: nil)
self.waitForExpectations(timeout: 10, handler: nil)
}
// MARK: XCTestCase

View File

@@ -20,8 +20,8 @@ class BaseTestDataTestCase: BaseTestCase {
let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(localeIdentifier: "en_US_POSIX")
formatter.timeZone = TimeZone(name: "UTC")
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(identifier: "UTC")
formatter.calendar = Calendar(identifier: Calendar.Identifier.gregorian)
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ"
return formatter
@@ -42,9 +42,9 @@ class BaseTestDataTestCase: BaseTestCase {
let object = transaction.create(Into<TestEntity1>(configuration))
object.testEntityID = NSNumber(value: (configurationOrdinal * 100) + idIndex)
object.testNumber = idIndex
object.testNumber = NSNumber(value: idIndex)
object.testDate = self.dateFormatter.date(from: "2000-\(configurationOrdinal)-\(idIndex)T00:00:00Z")
object.testBoolean = (idIndex % 2) == 1
object.testBoolean = NSNumber(value: (idIndex % 2) == 1)
object.testDecimal = NSDecimalNumber(string: "\(idIndex)")
let string = "\(configuration ?? "nil"):TestEntity1:\(idIndex)"
@@ -59,9 +59,9 @@ class BaseTestDataTestCase: BaseTestCase {
let object = transaction.create(Into<TestEntity2>(configuration))
object.testEntityID = NSNumber(value: (configurationOrdinal * 200) + idIndex)
object.testNumber = idIndex
object.testNumber = NSNumber(value: idIndex)
object.testDate = self.dateFormatter.date(from: "2000-\(configurationOrdinal)-\(idIndex)T00:00:00Z")
object.testBoolean = (idIndex % 2) == 1
object.testBoolean = NSNumber(value: (idIndex % 2) == 1)
object.testDecimal = NSDecimalNumber(string: "\(idIndex)")
let string = "\(configuration ?? "nil"):TestEntity2:\(idIndex)"
@@ -70,7 +70,7 @@ class BaseTestDataTestCase: BaseTestCase {
}
}
}
transaction.commitAndWait()
_ = transaction.commitAndWait()
}
}
}