My view model is as such:
public class MainTabBarViewModel: MainTabBarInputs {
unowned var output: MainTabBarOutputs
...
}
where the view controller is this:
class ViewController: MainTabBarOutputs {
var viewModel: MainTabBarInputs!
}
I'm trying to write a unit test to test for the retain cycle:
class MainTabBarViewModelTests: XCTestCase {
var viewModel: MainTabBarViewModel!
var viewController: MockMainTabBarViewController!
func testRetainViewController() {
viewController = nil
// TODO how do you test this
expect(self.viewModel.output).to(beNil())
// crashes because I can't
// reference an unowned pointer that's deallocated.
}
I know if I changed my reference to be weak
I could test this, but what if I wanted to leave it as unowned
?