From 35196fc9bbd71a99f3851fc4dcf6c8ac39a5b0bc Mon Sep 17 00:00:00 2001 From: Khoa Pham Date: Thu, 14 Sep 2017 15:08:38 +0200 Subject: [PATCH] Update AsyncStorageTests --- .../iOS/Tests/Storage/AsyncStorageTests.swift | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift index 132fab7..2873962 100644 --- a/Tests/iOS/Tests/Storage/AsyncStorageTests.swift +++ b/Tests/iOS/Tests/Storage/AsyncStorageTests.swift @@ -48,10 +48,10 @@ final class AAsyncStorageTests: XCTestCase { then("all are removed") { storage.existsObject(ofType: Int.self, forKey: "key-99", completion: { result in switch result { - case .value(let exists): - XCTAssertTrue(exists) - default: + case .value: XCTFail() + default: + break } }) } @@ -59,26 +59,27 @@ final class AAsyncStorageTests: XCTestCase { wait(for: 0.1) } - /* - func testManyOperations() throws { + func testManyOperations() { var number = 0 let iterationCount = 10_000 - try when("performs lots of operations") { + when("performs lots of operations") { DispatchQueue.concurrentPerform(iterations: iterationCount) { _ in - do { - number += 1 - try storage.setObject(number, forKey: "number") - } catch { - XCTFail() - } + number += 1 + print(number) + storage.setObject(number, forKey: "number", completion: { _ in }) } } - try then("all operation must complete") { - let number = try storage.object(forKey: "number") as Int - XCTAssertEqual(number, iterationCount) + then("all operation must complete") { + storage.object(forKey: "number", completion: { (result: Result) in + switch result { + case .value(let cachedNumber): + XCTAssertEqual(cachedNumber, iterationCount) + default: + XCTFail() + } + }) } } - */ }