Skip to content

Commit

Permalink
Add UserCollectionViewControllerFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Mar 23, 2024
1 parent 04d9ef4 commit c145614
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
5 changes: 5 additions & 0 deletions SWDestinyTrades/Classes/TabBar/SWDTabBarFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ final class SWDTabBarFactory {
let factory = PeopleListViewControllerFactory(database: database)
return factory.createViewController()
}

func makeUserCollection(with database: DatabaseProtocol?) -> UIViewController {
let factory = UserCollectionViewControllerFactory(database: database)
return factory.createViewController()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ final class SWDTabBarViewController: UITabBarController {
loansTab.tabBarItem = UITabBarItem(title: L10n.loans, image: Asset.Tabbar.icLoans.image, selectedImage: nil)

// Create UserCollectionViewController Tab
let collectionTab = UINavigationController(rootViewController: UserCollectionViewController(database: database))
let collectionTab = UINavigationController(rootViewController: factory.makeUserCollection(with: database))
collectionTab.tabBarItem = UITabBarItem(title: L10n.collection, image: Asset.Tabbar.icCollection.image, selectedImage: nil)

viewControllers = [setsTab, decktab, loansTab, collectionTab]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UserCollectionViewControllerFactory.swift
// SWDestinyTrades
//
// Created by Diogo Autilio on 22/03/24.
// Copyright © 2024 Diogo Autilio. All rights reserved.
//

import Foundation
import UIKit

final class UserCollectionViewControllerFactory: ViewControllerFactory {

private let database: DatabaseProtocol?

init(database: DatabaseProtocol?) {
self.database = database
}

func createViewController() -> UIViewController {
let view = UserCollectionTableView()
let viewController = UserCollectionViewController(with: view, database: database)
return viewController
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// UserCollectionViewControllerFactoryTests.swift
// SWDestinyTradesTests
//
// Created by Diogo Autilio on 22/03/24.
// Copyright © 2024 Diogo Autilio. All rights reserved.
//

import Foundation
import XCTest

@testable import SWDestinyTrades

final class UserCollectionViewControllerFactoryTests: XCTestCase {

private var sut: UserCollectionViewControllerFactory!

override func setUp() {
super.setUp()
sut = UserCollectionViewControllerFactory(database: nil)
}

override func tearDown() {
sut = nil
super.tearDown()
}

func test_controller_creation() {
XCTAssertNotNil(sut.createViewController())
}
}
4 changes: 4 additions & 0 deletions SWDestinyTradesTests/TabBar/SWDTabBarFactoryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ final class SWDTabBarFactoryTests: XCTestCase {
func test_makePeopleList() {
XCTAssertNotNil(sut.makePeopleList(with: nil))
}

func test_makeUserCollection() {
XCTAssertNotNil(sut.makeUserCollection(with: nil))
}
}

0 comments on commit c145614

Please sign in to comment.