-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from tinkoff-mobile-tech/unit_tests
Added unit tests
- Loading branch information
Showing
46 changed files
with
1,840 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// Dispatcher.swift | ||
// TinkoffID | ||
// | ||
// Created by Dmitry on 19.01.2021. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Объект, умеющий выполнять определенные блоки кода | ||
protocol Dispatcher { | ||
/// Выполняет блок кода | ||
func dispatch(_ block: @escaping () -> Void) | ||
} | ||
|
||
extension DispatchQueue: Dispatcher { | ||
func dispatch(_ block: @escaping () -> Void) { | ||
async(execute: block) | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
Development/Source/API/RequestProcessor/IURLRequestProcessor.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,35 @@ | ||
// | ||
// IURLRequestProcessor.swift | ||
// TinkoffID | ||
// | ||
// Created by Dmitry on 19.01.2021. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Объект, выполняющий сетевые запросы | ||
protocol IURLRequestProcessor { | ||
|
||
/// Выполняет сетевой запрос | ||
/// - Parameters: | ||
/// - request: Запрос | ||
/// - completion: Коллбек с результатом выполнения | ||
func process(_ request: URLRequest, completion: @escaping (Result<Data, Error>) -> Void) | ||
} | ||
|
||
extension URLSession: IURLRequestProcessor { | ||
|
||
enum Error: Swift.Error { | ||
case unknown | ||
} | ||
|
||
func process(_ request: URLRequest, completion: @escaping (Result<Data, Swift.Error>) -> Void) { | ||
dataTask(with: request) { data, response, error in | ||
guard let data = data else { | ||
return completion(.failure(error ?? Error.unknown)) | ||
} | ||
|
||
completion(.success(data)) | ||
}.resume() | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
Development/Source/AppLaunching/IAppLauncher/Utils/Router/IURLRouter.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,27 @@ | ||
// | ||
// IURLRouter.swift | ||
// TinkoffID | ||
// | ||
// Created by Dmitry on 20.01.2021. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Роутер URL | ||
protocol IURLRouter { | ||
/// Возвращает `true` если заданный URL может быть открыт | ||
func canOpenURL(_ url: URL) -> Bool | ||
|
||
/// Открывает заданный URL и возвращает `true` если открытие удалось | ||
func open(_ url: URL) -> Bool | ||
} | ||
|
||
extension UIApplication: IURLRouter { | ||
func open(_ url: URL) -> Bool { | ||
guard canOpenURL(url) else { return false } | ||
|
||
open(url, options: [:], completionHandler: nil) | ||
|
||
return true | ||
} | ||
} |
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
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
Oops, something went wrong.