Skip to content

Commit

Permalink
Add AddToDeckInteractor
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Jan 2, 2024
1 parent e420374 commit cdaf9cb
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
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()
}
}
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)
}
}

0 comments on commit cdaf9cb

Please sign in to comment.