-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Closed
Copy link
Description
Short description of the issue:
Binary operator '==' cannot be applied to two '[Recorded<Event>]' operands. Void isn't implement Equatable.
What actually happens:
Hi,
Recently I tried to use RxTest with ViewModel architecture in my project. But I got some wrong from Xcode, that "Binary operator '==' cannot be applied to two '[Recorded<Event>]' operands" error log.
There is my MVVM code:
protocol ProfileViewModelInputs {
func didTapSettingButton()
}
protocol ProfileViewModelOutputs {
var showSetting: Signal<Void> { get }
}
final class ProfileViewModel {
let showSetting: Signal<Void>
init() {
showSetting = tappingSettingButtonSubject.asSignal()
}
fileprivate let tappingSettingButtonSubject = PublishRelay<Void>()
func didTapSettingButton() {
tappingSettingButtonSubject.accept(())
}
}And my test code:
class ProfileViewModelTests: XCTestCase {
private var viewModel: ProfileViewModel!
private var disposeBag: DisposeBag!
private var schedule: TestScheduler!
override func setUp() {
super.setUp()
viewModel = ProfileViewModel()
disposeBag = DisposeBag()
schedule = TestScheduler(initialClock: 0)
}
override func tearDown() {
super.tearDown()
viewModel = nil
disposeBag = nil
schedule = nil
}
func test_tapping_setting_button() {
let tapObserver = schedule.createObserver(Void.self)
viewModel.outputs.showSetting
.debug(#function)
.emit(to: tapObserver)
.disposed(by: disposeBag)
schedule.start()
viewModel.inputs.didTapSettingButton()
let expectedEvents = [
next(0, ())
]
let tapEvents = tapObserver.events
XCTAssert("\(tapObserver.events)" == "\(expectedEvents)")
}
}In this code, I can't use tapObserver.events == expectedEvents because Void is not implemented Equatable. Only I can transform it to string. How to solve this problem?
Thanks for you help.
Metadata
Metadata
Assignees
Labels
No labels