-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Box for BoardProducer to avoid reference management
- Loading branch information
Showing
6 changed files
with
84 additions
and
16 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
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,41 @@ | ||
// | ||
// ProducerTests.swift | ||
// Boardy_Tests | ||
// | ||
// Created by NGUYEN CHI CONG on 10/1/21. | ||
// Copyright © 2021 [iF] Solution. All rights reserved. | ||
// | ||
|
||
@testable import Boardy | ||
import XCTest | ||
|
||
private class StubBoard: Board, ActivatableBoard { | ||
func activate(withOption option: Any?) {} | ||
} | ||
|
||
class ProducerTests: XCTestCase { | ||
override func setUpWithError() throws { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
func testBoxedProducer() throws { | ||
var producer: BoardProducer? = BoardProducer(registrations: []) | ||
|
||
let boxedProducer = BoardDynamicProducerBox(producer: producer) | ||
XCTAssertNotNil(boxedProducer.producer) | ||
|
||
boxedProducer.registerBoard("add-one") { id in | ||
StubBoard(identifier: id) | ||
} | ||
|
||
let regBoard = producer?.produceBoard(identifier: "add-one") | ||
XCTAssertNotNil(regBoard) | ||
|
||
producer = nil | ||
XCTAssertNil(boxedProducer.producer) | ||
} | ||
} |