-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
AcquiringRequestBuilderTests
- Loading branch information
Showing
13 changed files
with
487 additions
and
9 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
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
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
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
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
15 changes: 15 additions & 0 deletions
15
...offASDKCore/TinkoffASDKCoreTests/Infrastructure/Extensions/FinishAuthorizeData+Fake.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,15 @@ | ||
// | ||
// FinishAuthorizeData+Fake.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
extension FinishAuthorizeData { | ||
static func fake() -> FinishAuthorizeData { | ||
FinishAuthorizeData(paymentId: "id", paymentSource: .savedCard(cardId: "123", cvv: "213")) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
TinkoffASDKCore/TinkoffASDKCoreTests/Infrastructure/Extensions/PaymentInitData+Fake.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,15 @@ | ||
// | ||
// PaymentInitData+Fake.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
extension PaymentInitData { | ||
static func fake() -> PaymentInitData { | ||
PaymentInitData(amount: Int64(5000), orderId: "order_id", customerKey: "key") | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
TinkoffASDKCore/TinkoffASDKCoreTests/Infrastructure/Mocks/CardDataFormatterMock.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,60 @@ | ||
// | ||
// CardDataFormatterMock.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
final class CardDataFormatterMock: ICardDataFormatter { | ||
|
||
// MARK: - formatCardDataCardNumberExpDate | ||
|
||
typealias FormatCardDataCardNumberExpDateArguments = (cardNumber: String, expDate: String, cvv: String) | ||
|
||
var formatCardDataCardNumberExpDateCallsCount = 0 | ||
var formatCardDataCardNumberExpDateReceivedArguments: FormatCardDataCardNumberExpDateArguments? | ||
var formatCardDataCardNumberExpDateReceivedInvocations: [FormatCardDataCardNumberExpDateArguments?] = [] | ||
var formatCardDataCardNumberExpDateReturnValue: String! | ||
|
||
func formatCardData(cardNumber: String, expDate: String, cvv: String) -> String { | ||
formatCardDataCardNumberExpDateCallsCount += 1 | ||
let arguments = (cardNumber, expDate, cvv) | ||
formatCardDataCardNumberExpDateReceivedArguments = arguments | ||
formatCardDataCardNumberExpDateReceivedInvocations.append(arguments) | ||
return formatCardDataCardNumberExpDateReturnValue | ||
} | ||
|
||
// MARK: - formatCardDataCardIdCvv | ||
|
||
typealias FormatCardDataCardIdCvvArguments = (cardId: String, cvv: String?) | ||
|
||
var formatCardDataCardIdCvvCallsCount = 0 | ||
var formatCardDataCardIdCvvReceivedArguments: FormatCardDataCardIdCvvArguments? | ||
var formatCardDataCardIdCvvReceivedInvocations: [FormatCardDataCardIdCvvArguments?] = [] | ||
var formatCardDataCardIdCvvReturnValue: String! | ||
|
||
func formatCardData(cardId: String, cvv: String?) -> String { | ||
formatCardDataCardIdCvvCallsCount += 1 | ||
let arguments = (cardId, cvv) | ||
formatCardDataCardIdCvvReceivedArguments = arguments | ||
formatCardDataCardIdCvvReceivedInvocations.append(arguments) | ||
return formatCardDataCardIdCvvReturnValue | ||
} | ||
} | ||
|
||
// MARK: - Resets | ||
|
||
extension CardDataFormatterMock { | ||
func fullReset() { | ||
formatCardDataCardNumberExpDateCallsCount = 0 | ||
formatCardDataCardNumberExpDateReceivedArguments = nil | ||
formatCardDataCardNumberExpDateReceivedInvocations = [] | ||
|
||
formatCardDataCardIdCvvCallsCount = 0 | ||
formatCardDataCardIdCvvReceivedArguments = nil | ||
formatCardDataCardIdCvvReceivedInvocations = [] | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...SDKCore/TinkoffASDKCoreTests/Infrastructure/Mocks/EnvironmentParametersProviderMock.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,13 @@ | ||
// | ||
// File.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
final class EnvironmentParametersProviderMock: IEnvironmentParametersProvider { | ||
var environmentParameters: [String: String] = [:] | ||
} |
14 changes: 14 additions & 0 deletions
14
TinkoffASDKCore/TinkoffASDKCoreTests/Infrastructure/Mocks/IPAddressProviderMock.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,14 @@ | ||
// | ||
// IPAddressProviderMock.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
public final class IPAddressProviderMock: IIPAddressProvider { | ||
public init() {} | ||
public var ipAddress: IPAddress? | ||
} |
19 changes: 19 additions & 0 deletions
19
TinkoffASDKCore/TinkoffASDKCoreTests/Infrastructure/Mocks/PublicKeyProviderMock.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,19 @@ | ||
// | ||
// PublicKeyProviderMock.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
final class PublicKeyProviderMock: IPublicKeyProvider { | ||
|
||
var publicKey: SecKey { | ||
get { return underlyingPublicKey } | ||
set(value) { underlyingPublicKey = value } | ||
} | ||
|
||
var underlyingPublicKey: SecKey! | ||
} |
60 changes: 60 additions & 0 deletions
60
TinkoffASDKCore/TinkoffASDKCoreTests/Infrastructure/Mocks/RSAEncryptorMock.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,60 @@ | ||
// | ||
// RSAEncryptorMock.swift | ||
// TinkoffASDKCore-Unit-Tests | ||
// | ||
// Created by Никита Васильев on 21.07.2023. | ||
// | ||
|
||
import Foundation | ||
@testable import TinkoffASDKCore | ||
|
||
final class RSAEncryptorMock: IRSAEncryptor { | ||
|
||
// MARK: - createPublicSecKey | ||
|
||
typealias CreatePublicSecKeyArguments = String | ||
|
||
var createPublicSecKeyCallsCount = 0 | ||
var createPublicSecKeyReceivedArguments: CreatePublicSecKeyArguments? | ||
var createPublicSecKeyReceivedInvocations: [CreatePublicSecKeyArguments?] = [] | ||
var createPublicSecKeyReturnValue: SecKey? | ||
|
||
func createPublicSecKey(publicKey: String) -> SecKey? { | ||
createPublicSecKeyCallsCount += 1 | ||
let arguments = publicKey | ||
createPublicSecKeyReceivedArguments = arguments | ||
createPublicSecKeyReceivedInvocations.append(arguments) | ||
return createPublicSecKeyReturnValue | ||
} | ||
|
||
// MARK: - encrypt | ||
|
||
typealias EncryptArguments = (string: String, publicKey: SecKey) | ||
|
||
var encryptCallsCount = 0 | ||
var encryptReceivedArguments: EncryptArguments? | ||
var encryptReceivedInvocations: [EncryptArguments?] = [] | ||
var encryptReturnValue: String? | ||
|
||
func encrypt(string: String, publicKey: SecKey) -> String? { | ||
encryptCallsCount += 1 | ||
let arguments = (string, publicKey) | ||
encryptReceivedArguments = arguments | ||
encryptReceivedInvocations.append(arguments) | ||
return encryptReturnValue | ||
} | ||
} | ||
|
||
// MARK: - Resets | ||
|
||
extension RSAEncryptorMock { | ||
func fullReset() { | ||
createPublicSecKeyCallsCount = 0 | ||
createPublicSecKeyReceivedArguments = nil | ||
createPublicSecKeyReceivedInvocations = [] | ||
|
||
encryptCallsCount = 0 | ||
encryptReceivedArguments = nil | ||
encryptReceivedInvocations = [] | ||
} | ||
} |
Oops, something went wrong.