Open gtatgh opened 5 years ago
Hi @gtatgh
Do you want to add tests to RxBluetoothKit
library or to your project?
If you want to use CentralManager
mock in RxBluetoothKit
tests you should use _CentralManager
instead. This is autogenerated mock of CentalManager
class. Example how it is used can be found in tests in the Tests
folder.
If you want to mock CentralManager
in your own project you can create a protocol with methods which you want to use in your tests and use it instead CentralManager
in your code. CentralManager
should implement this protocol and you can also create a mock which also implements this protocol and use it in your tests.. If you are interested in more details please ask.
Hello @minixT,
yes I want to mock CentralManager
in my own project, specially in BluetoothHandler
. I can create a protocol and extend it in BluetoothHandler
. What I want is to receive e.g. ScannedPeripheral
from CentralManager
.
@minixT I am about to do some testing and was looking into this... My question to you is: If it is the case that you recommend using a protocol for mocking, why does the main codebase not use that exact same approach? Peripheral could have been a protocol, but it isn't. Why?
Is your feature request related to a problem? Please describe. I have a wrapper class
BluetoothHandler
around ofCentralManager
which configure the use ofCentralManager
, like in your example. So, how can I mockCentralManager
in unit tests e.g. for scanning?Describe the solution you'd like I would like to test the logic of
BluetoothHandler
.Additional context