Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
F24C45E22C409D42000C6C72 /* InAppPurchasePluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */; };
F276940B2C47268700277144 /* ProductRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */; };
F27694112C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */; };
F27694172C49DBCA00277144 /* FIATransactionCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */; };
F295AD3A2C1256DD0067C78A /* Stubs.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD392C1256DD0067C78A /* Stubs.m */; };
F295AD442C1256F50067C78A /* FIATransactionCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */; };
F295AD452C1256F50067C78A /* PaymentQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */; };
F295AD462C1256F50067C78A /* TranslatorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F295AD402C1256F50067C78A /* TranslatorTests.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -78,9 +78,9 @@
F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InAppPurchasePluginTests.swift; path = ../../shared/RunnerTests/InAppPurchasePluginTests.swift; sourceTree = "<group>"; };
F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProductRequestHandlerTests.swift; path = ../../shared/RunnerTests/ProductRequestHandlerTests.swift; sourceTree = "<group>"; };
F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIAPPaymentQueueDeleteTests.swift; path = ../../shared/RunnerTests/FIAPPaymentQueueDeleteTests.swift; sourceTree = "<group>"; };
F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIATransactionCacheTests.swift; path = ../../shared/RunnerTests/FIATransactionCacheTests.swift; sourceTree = "<group>"; };
F295AD362C1251300067C78A /* Stubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stubs.h; path = ../../shared/RunnerTests/Stubs.h; sourceTree = "<group>"; };
F295AD392C1256DD0067C78A /* Stubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Stubs.m; path = ../../shared/RunnerTests/Stubs.m; sourceTree = "<group>"; };
F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIATransactionCacheTests.m; path = ../../shared/RunnerTests/FIATransactionCacheTests.m; sourceTree = "<group>"; };
F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PaymentQueueTests.m; path = ../../shared/RunnerTests/PaymentQueueTests.m; sourceTree = "<group>"; };
F295AD402C1256F50067C78A /* TranslatorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TranslatorTests.m; path = ../../shared/RunnerTests/TranslatorTests.m; sourceTree = "<group>"; };
F6E5D5F926131C4800C68BED /* Configuration.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Configuration.storekit; sourceTree = "<group>"; };
Expand Down Expand Up @@ -186,10 +186,10 @@
A59001A521E69658004A3E5E /* RunnerTests */ = {
isa = PBXGroup;
children = (
F27694162C49DBCA00277144 /* FIATransactionCacheTests.swift */,
F27694102C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift */,
F24C45E12C409D41000C6C72 /* InAppPurchasePluginTests.swift */,
F276940A2C47268700277144 /* ProductRequestHandlerTests.swift */,
F295AD3E2C1256F50067C78A /* FIATransactionCacheTests.m */,
F295AD3F2C1256F50067C78A /* PaymentQueueTests.m */,
F295AD402C1256F50067C78A /* TranslatorTests.m */,
F295AD392C1256DD0067C78A /* Stubs.m */,
Expand Down Expand Up @@ -436,10 +436,10 @@
F24C45E22C409D42000C6C72 /* InAppPurchasePluginTests.swift in Sources */,
F22BF91C2BC9B40B00713878 /* SwiftStubs.swift in Sources */,
F295AD452C1256F50067C78A /* PaymentQueueTests.m in Sources */,
F295AD442C1256F50067C78A /* FIATransactionCacheTests.m in Sources */,
F276940B2C47268700277144 /* ProductRequestHandlerTests.swift in Sources */,
F295AD462C1256F50067C78A /* TranslatorTests.m in Sources */,
F295AD3A2C1256DD0067C78A /* Stubs.m in Sources */,
F27694172C49DBCA00277144 /* FIATransactionCacheTests.swift in Sources */,
F27694112C49BF6F00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
F24C45E42C409D87000C6C72 /* InAppPurchasePluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */; };
F27694092C4724B200277144 /* ProductRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */; };
F27694132C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */; };
F27694192C49DBE800277144 /* FIATransactionCacheTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */; };
F2C3A7412BD9D33D000D35F2 /* Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2C3A7402BD9D33D000D35F2 /* Stubs.swift */; };
F79BDC122905FBF700E3999D /* FIATransactionCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */; };
F79BDC182905FC1800E3999D /* PaymentQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC172905FC1800E3999D /* PaymentQueueTests.m */; };
F79BDC1C2905FC3200E3999D /* Stubs.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC1B2905FC3200E3999D /* Stubs.m */; };
F79BDC1E2905FC3900E3999D /* TranslatorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC1D2905FC3900E3999D /* TranslatorTests.m */; };
Expand Down Expand Up @@ -94,10 +94,10 @@
F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = InAppPurchasePluginTests.swift; path = ../../shared/RunnerTests/InAppPurchasePluginTests.swift; sourceTree = "<group>"; };
F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ProductRequestHandlerTests.swift; path = ../../shared/RunnerTests/ProductRequestHandlerTests.swift; sourceTree = "<group>"; };
F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIAPPaymentQueueDeleteTests.swift; path = ../../shared/RunnerTests/FIAPPaymentQueueDeleteTests.swift; sourceTree = "<group>"; };
F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FIATransactionCacheTests.swift; path = ../../shared/RunnerTests/FIATransactionCacheTests.swift; sourceTree = "<group>"; };
F2C3A73F2BD9D33D000D35F2 /* RunnerTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RunnerTests-Bridging-Header.h"; sourceTree = "<group>"; };
F2C3A7402BD9D33D000D35F2 /* Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stubs.swift; sourceTree = "<group>"; };
F700DD0228E652A10004836B /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FIATransactionCacheTests.m; path = ../../shared/RunnerTests/FIATransactionCacheTests.m; sourceTree = "<group>"; };
F79BDC152905FC0500E3999D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../../shared/RunnerTests/Info.plist; sourceTree = "<group>"; };
F79BDC172905FC1800E3999D /* PaymentQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PaymentQueueTests.m; path = ../../shared/RunnerTests/PaymentQueueTests.m; sourceTree = "<group>"; };
F79BDC1B2905FC3200E3999D /* Stubs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Stubs.m; path = ../../shared/RunnerTests/Stubs.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -217,6 +217,7 @@
F700DD0328E652A10004836B /* RunnerTests */ = {
isa = PBXGroup;
children = (
F27694182C49DBE800277144 /* FIATransactionCacheTests.swift */,
F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */,
F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */,
F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */,
Expand All @@ -225,7 +226,6 @@
F79BDC152905FC0500E3999D /* Info.plist */,
F79BDC1B2905FC3200E3999D /* Stubs.m */,
F79BDC1D2905FC3900E3999D /* TranslatorTests.m */,
F79BDC112905FBF700E3999D /* FIATransactionCacheTests.m */,
F2C3A7402BD9D33D000D35F2 /* Stubs.swift */,
F2C3A73F2BD9D33D000D35F2 /* RunnerTests-Bridging-Header.h */,
);
Expand Down Expand Up @@ -468,8 +468,8 @@
F79BDC182905FC1800E3999D /* PaymentQueueTests.m in Sources */,
F79BDC1C2905FC3200E3999D /* Stubs.m in Sources */,
F27694092C4724B200277144 /* ProductRequestHandlerTests.swift in Sources */,
F79BDC122905FBF700E3999D /* FIATransactionCacheTests.m in Sources */,
F2C3A7412BD9D33D000D35F2 /* Stubs.swift in Sources */,
F27694192C49DBE800277144 /* FIATransactionCacheTests.swift in Sources */,
F27694132C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

This file was deleted.

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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   let dummyArray = [1, 2, 3]

let cache = FIATransactionCache()
cache.add(dummyArray, for: TransactionCacheKey.updatedTransactions)

XCTAssertEqual(
dummyArray, cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as! [Int])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use that unwrap function and avoid ! here?

let updatedTransactions = try XCTUnwrap(cache.getObjectsFor(TransactionCacheKey.updatedTransactions) as? [Int])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh yes, done

}

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)
}

func testClear() {
let fakeUpdatedTransactions: [Int] = [1, 2, 3]
let fakeRemovedTransactions: [String] = ["Remove 1", "Remove 2", "Remove 3"]
let fakeUpdatedDownloads: [String] = ["Download 1", "Download 2"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need the type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed all types

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)
}
}