mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-16 14:06:53 +01:00
Swift 3 master candidate
This commit is contained in:
@@ -364,21 +364,21 @@ final class TransactionTests: BaseTestCase {
|
||||
|
||||
let observer = TestListObserver()
|
||||
let monitor = stack.monitorList(
|
||||
From(TestEntity1),
|
||||
OrderBy(.Ascending("testEntityID"))
|
||||
From<TestEntity1>(),
|
||||
OrderBy(.ascending("testEntityID"))
|
||||
)
|
||||
monitor.addObserver(observer)
|
||||
|
||||
XCTAssertFalse(monitor.hasObjects())
|
||||
|
||||
var events = 0
|
||||
let willChangeExpectation = self.expectationForNotification(
|
||||
"listMonitorWillChange:",
|
||||
let willChangeExpectation = self.expectation(
|
||||
forNotification: "listMonitorWillChange:",
|
||||
object: observer,
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual(events, 0)
|
||||
XCTAssertEqual((note.userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertTrue(note.userInfo?.isEmpty != false)
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -386,8 +386,8 @@ final class TransactionTests: BaseTestCase {
|
||||
return events == 0
|
||||
}
|
||||
)
|
||||
let didInsertObjectExpectation = self.expectationForNotification(
|
||||
"listMonitor:didInsertObject:toIndexPath:",
|
||||
let didInsertObjectExpectation = self.expectation(
|
||||
forNotification: "listMonitor:didInsertObject:toIndexPath:",
|
||||
object: observer,
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
@@ -405,8 +405,8 @@ final class TransactionTests: BaseTestCase {
|
||||
XCTAssertEqual(indexPath?.row, 0)
|
||||
|
||||
let object = userInfo?["object"] as? TestEntity1
|
||||
XCTAssertEqual(object?.testBoolean, NSNumber(bool: true))
|
||||
XCTAssertEqual(object?.testNumber, NSNumber(integer: 1))
|
||||
XCTAssertEqual(object?.testBoolean, NSNumber(value: true))
|
||||
XCTAssertEqual(object?.testNumber, NSNumber(value: 1))
|
||||
XCTAssertEqual(object?.testDecimal, NSDecimalNumber(string: "1"))
|
||||
XCTAssertEqual(object?.testString, "nil:TestEntity1:1")
|
||||
defer {
|
||||
@@ -416,12 +416,12 @@ final class TransactionTests: BaseTestCase {
|
||||
return events == 1
|
||||
}
|
||||
)
|
||||
let didChangeExpectation = self.expectationForNotification(
|
||||
"listMonitorDidChange:",
|
||||
let didChangeExpectation = self.expectation(
|
||||
forNotification: "listMonitorDidChange:",
|
||||
object: observer,
|
||||
handler: { (note) -> Bool in
|
||||
|
||||
XCTAssertEqual((note.userInfo ?? [:]), NSDictionary())
|
||||
XCTAssertTrue(note.userInfo?.isEmpty != false)
|
||||
defer {
|
||||
|
||||
events += 1
|
||||
@@ -429,22 +429,22 @@ final class TransactionTests: BaseTestCase {
|
||||
return events == 2
|
||||
}
|
||||
)
|
||||
let saveExpectation = self.expectationWithDescription("save")
|
||||
let saveExpectation = self.expectation(description: "save")
|
||||
stack.beginSynchronous { (transaction) in
|
||||
|
||||
let object = transaction.create(Into(TestEntity1))
|
||||
object.testBoolean = NSNumber(bool: true)
|
||||
object.testNumber = NSNumber(integer: 1)
|
||||
let object = transaction.create(Into<TestEntity1>())
|
||||
object.testBoolean = NSNumber(value: true)
|
||||
object.testNumber = NSNumber(value: 1)
|
||||
object.testDecimal = NSDecimalNumber(string: "1")
|
||||
object.testString = "nil:TestEntity1:1"
|
||||
|
||||
switch transaction.commit() {
|
||||
|
||||
case .Success(let hasChanges):
|
||||
case .success(let hasChanges):
|
||||
XCTAssertTrue(hasChanges)
|
||||
saveExpectation.fulfill()
|
||||
|
||||
default:
|
||||
case .failure:
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@ Unleashing the real power of Core Data with the elegance and safety of Swift
|
||||
|
||||
* **Swift 3.0.1:** iOS 8+ / macOS 10.10+ / watchOS 2.0+ / tvOS 9.0+
|
||||
|
||||
* **New in CoreStore 2.0:** Objective-C support! All CoreStore types now have their corresponding Objective-C "bridging classes". Perfect for projects transitioning from Objective-C to Swift!
|
||||
|
||||
Upgrading from CoreStore 2.x to 3.x? Check out the [new features](#new-in-corestore-20) and make sure to read the [Migration guide](#upgrading-from-2xx-to-3xx).
|
||||
Upgrading from CoreStore 2.x to 3.x? Check out the [new features](#features) and make sure to read the [Migration guide](#upgrading-from-2xx-to-3xx).
|
||||
|
||||
|
||||
## Why use CoreStore?
|
||||
|
||||
@@ -140,7 +140,7 @@ internal extension NSManagedObjectContext {
|
||||
}
|
||||
|
||||
@nonobjc
|
||||
internal func saveSynchronously(waitForMerge waitForMerge: Bool) -> SaveResult {
|
||||
internal func saveSynchronously(waitForMerge: Bool) -> SaveResult {
|
||||
|
||||
var result = SaveResult(hasChanges: false)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public final class SynchronousDataTransaction: BaseDataTransaction {
|
||||
public func commit() -> SaveResult {
|
||||
|
||||
CoreStore.assert(
|
||||
self.transactionQueue.isCurrentExecutionContext(),
|
||||
self.transactionQueue.cs_isCurrentExecutionContext(),
|
||||
"Attempted to commit a \(cs_typeName(self)) outside its designated queue."
|
||||
)
|
||||
CoreStore.assert(
|
||||
|
||||
Reference in New Issue
Block a user