-
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.
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
SWDestinyTrades/Classes/AddToDeck/Interactor/AddToDeckInteractor.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,26 @@ | ||
// | ||
// AddToDeckInteractor.swift | ||
// SWDestinyTrades | ||
// | ||
// Created by Diogo Autilio on 02/01/24. | ||
// Copyright © 2024 Diogo Autilio. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol AddToDeckInteractorProtocol { | ||
func retrieveAllCards() async throws -> [CardDTO] | ||
} | ||
|
||
final class AddToDeckInteractor: AddToDeckInteractorProtocol { | ||
|
||
private let service: SWDestinyServiceProtocol | ||
|
||
init(service: SWDestinyServiceProtocol = SWDestinyService()) { | ||
self.service = service | ||
} | ||
|
||
func retrieveAllCards() async throws -> [CardDTO] { | ||
return try await service.retrieveAllCards() | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
SWDestinyTradesTests/Screens/AddToDeck/Interactor/AddToDeckInteractorTests.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,39 @@ | ||
// | ||
// AddToDeckInteractorTests.swift | ||
// SWDestinyTradesTests | ||
// | ||
// Created by Diogo Autilio on 02/01/24. | ||
// Copyright © 2024 Diogo Autilio. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import XCTest | ||
|
||
@testable import SWDestinyTrades | ||
|
||
final class AddToDeckInteractorTests: XCTestCase { | ||
|
||
private var sut: AddToDeckInteractor! | ||
private var service: SWDestinyService! | ||
private var client: HttpClientMock! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
client = HttpClientMock() | ||
service = SWDestinyService(client: client) | ||
sut = AddToDeckInteractor(service: service) | ||
} | ||
|
||
override func tearDown() { | ||
client = nil | ||
service = nil | ||
sut = nil | ||
super.tearDown() | ||
} | ||
|
||
func test_retrieveAllCards() async throws { | ||
let cards = try await sut.retrieveAllCards() | ||
|
||
XCTAssertNotNil(cards) | ||
} | ||
} |