-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[in_app_purchase_storekit] Migrate FIATransactionCacheTests.m to.Swift #7172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5c30f41
582941b
a9a957d
f2fa2c7
372ac10
87c0655
61c625a
c264198
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../shared/RunnerTests/FIATransactionCacheTests.swift |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../shared/RunnerTests/FIATransactionCacheTests.swift |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import XCTest | ||
|
|
||
| @testable import in_app_purchase_storekit | ||
|
|
||
| final class FIATransactionCacheTests: XCTestCase { | ||
|
|
||
| func testAddObjectsForNewKey() { | ||
| let dummyArray: [Int] = [1, 2, 3] | ||
| let cache = FIATransactionCache() | ||
| cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions) | ||
|
|
||
| XCTAssertEqual( | ||
| dummyArray, cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as! [Int]) | ||
|
||
| } | ||
|
|
||
| func testAddObjectsForExistingKey() { | ||
| let dummyArray: [Int] = [1, 2, 3] | ||
| let cache = FIATransactionCache() | ||
| cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions) | ||
|
|
||
| XCTAssertEqual( | ||
| dummyArray, cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as! [Int]) | ||
|
|
||
| cache.add([4, 5, 6], for: TransactionCacheKey.updatedTransactions) | ||
|
|
||
| let expected: [Int] = [1, 2, 3, 4, 5, 6] | ||
| XCTAssertEqual(expected, cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as! [Int]) | ||
| } | ||
|
|
||
| func testGetObjectsForNonExistingKey() { | ||
| let cache = FIATransactionCache() | ||
| XCTAssert(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).count == 0) | ||
LouiseHsu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| func testClear() { | ||
| let fakeUpdatedTransactions: [Int] = [1, 2, 3] | ||
| let fakeRemovedTransactions: [String] = ["Remove 1", "Remove 2", "Remove 3"] | ||
| let fakeUpdatedDownloads: [String] = ["Download 1", "Download 2"] | ||
|
||
| let cache = FIATransactionCache() | ||
| cache.add(fakeUpdatedTransactions, for: TransactionCacheKey.updatedTransactions) | ||
| cache.add(fakeRemovedTransactions, for: TransactionCacheKey.removedTransactions) | ||
| cache.add(fakeUpdatedDownloads, for: TransactionCacheKey.updatedDownloads) | ||
|
|
||
| XCTAssertEqual( | ||
| fakeUpdatedTransactions, | ||
| cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as! [Int]) | ||
| XCTAssertEqual( | ||
| fakeRemovedTransactions, | ||
| cache.getObjectsFor(TransactionCacheKey.removedTransactions) as! [String]) | ||
| XCTAssertEqual( | ||
| fakeUpdatedDownloads, cache.getObjectsFor(TransactionCacheKey.updatedDownloads) as! [String]) | ||
|
|
||
| cache.clear() | ||
|
|
||
| XCTAssert(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).count == 0) | ||
| XCTAssert(cache.getObjectsFor(TransactionCacheKey.removedTransactions).count == 0) | ||
| XCTAssert(cache.getObjectsFor(TransactionCacheKey.updatedDownloads).count == 0) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.