forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[in_app_purchase_storekit] Migrate FIATransactionCacheTests.m to.Swift (
flutter#7172) Part of flutter#151624
- Loading branch information
Showing
8 changed files
with
80 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
..._app_purchase/in_app_purchase_storekit/example/ios/RunnerTests/FIATransactionCacheTests.m
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
..._purchase/in_app_purchase_storekit/example/ios/RunnerTests/FiaTransactionCacheTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../shared/RunnerTests/FIATransactionCacheTests.swift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...pp_purchase/in_app_purchase_storekit/example/macos/RunnerTests/FIATransactionCacheTests.m
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...urchase/in_app_purchase_storekit/example/macos/RunnerTests/FIATransactionCacheTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../shared/RunnerTests/FIATransactionCacheTests.swift |
63 changes: 0 additions & 63 deletions
63
...p_purchase/in_app_purchase_storekit/example/shared/RunnerTests/FIATransactionCacheTests.m
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
...rchase/in_app_purchase_storekit/example/shared/RunnerTests/FIATransactionCacheTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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() throws { | ||
let dummyArray = [1, 2, 3] | ||
let cache = FIATransactionCache() | ||
cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions) | ||
|
||
let updatedTransactions = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int]) | ||
XCTAssertEqual(dummyArray, updatedTransactions) | ||
} | ||
|
||
func testAddObjectsForExistingKey() throws { | ||
let dummyArray = [1, 2, 3] | ||
let cache = FIATransactionCache() | ||
cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions) | ||
|
||
let firstUpdatedTransactions = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int]) | ||
XCTAssertEqual(dummyArray, firstUpdatedTransactions) | ||
|
||
cache.add([4, 5, 6], for: TransactionCacheKey.updatedTransactions) | ||
|
||
let expected = [1, 2, 3, 4, 5, 6] | ||
let secondUpdatedTransactions = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int]) | ||
XCTAssertEqual(expected, secondUpdatedTransactions) | ||
} | ||
|
||
func testGetObjectsForNonExistingKey() { | ||
let cache = FIATransactionCache() | ||
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).isEmpty) | ||
} | ||
|
||
func testClear() throws { | ||
let fakeUpdatedTransactions = [1, 2, 3] | ||
let fakeRemovedTransactions = ["Remove 1", "Remove 2", "Remove 3"] | ||
let fakeUpdatedDownloads = ["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) | ||
|
||
let updatedTransactions = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int]) | ||
let removedTransactions = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.removedTransactions) as? [String]) | ||
let updatedDownloads = try XCTUnwrap( | ||
cache.getObjectsFor(TransactionCacheKey.updatedDownloads) as? [String]) | ||
|
||
XCTAssertEqual(fakeUpdatedTransactions, updatedTransactions) | ||
XCTAssertEqual(fakeRemovedTransactions, removedTransactions) | ||
XCTAssertEqual(fakeUpdatedDownloads, updatedDownloads) | ||
|
||
cache.clear() | ||
|
||
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedTransactions).isEmpty) | ||
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.removedTransactions).isEmpty) | ||
XCTAssertTrue(cache.getObjectsFor(TransactionCacheKey.updatedDownloads).isEmpty) | ||
} | ||
} |