{"action":"closed","issue":{"url":"https://api.github.com/repos/Moya/Moya/issues/1650","repository_url":"https://api.github.com/repos/Moya/Moya","labels_url":"https://api.github.com/repos/Moya/Moya/issues/1650/labels{/name}","comments_url":"https://api.github.com/repos/Moya/Moya/issues/1650/comments","events_url":"https://api.github.com/repos/Moya/Moya/issues/1650/events","html_url":"https://github.com/Moya/Moya/issues/1650","id":316661120,"number":1650,"title":"How to use delayed stub with RxTest.TestScheduler?","user":{"login":"gobetti","id":12944582,"avatar_url":"https://avatars0.githubusercontent.com/u/12944582?v=4","gravatar_id":"","url":"https://api.github.com/users/gobetti","html_url":"https://github.com/gobetti","followers_url":"https://api.github.com/users/gobetti/followers","following_url":"https://api.github.com/users/gobetti/following{/other_user}","gists_url":"https://api.github.com/users/gobetti/gists{/gist_id}","starred_url":"https://api.github.com/users/gobetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gobetti/subscriptions","organizations_url":"https://api.github.com/users/gobetti/orgs","repos_url":"https://api.github.com/users/gobetti/repos","events_url":"https://api.github.com/users/gobetti/events{/privacy}","received_events_url":"https://api.github.com/users/gobetti/received_events","type":"User","site_admin":false},"labels":[{"id":122272862,"url":"https://api.github.com/repos/Moya/Moya/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-04-23T04:53:32Z","updated_at":"2018-05-22T05:17:28Z","closed_at":"2018-05-22T05:17:28Z","author_association":"NONE","body":"Moya version: 11.0.1\r\n\r\n**Context:**\r\nHi! I'm reasonably new to Moya so I may be overlooking this, hence this is just a question. I've recently migrated to RxTest and all tests using `immediatelyStub` worked perfectly, but I'm having trouble with the cases where I need `delayedStub`. I'd really like to simulate network work in my unit test (while still using stubs) and count on the perfect precision of RxTest when it comes to comparing events timestamps, however the `delayedStub` seems (in a first look) stuck to real world time units instead of being able to use `TestScheduler`'s virtual time.\r\n\r\nSo when I noticed that the following code is inside an `open`-declared method, my first thought was to subclass `MoyaProvider`:\r\n```swift\r\ncase .delayed(let delay):\r\n    let killTimeOffset = Int64(CDouble(delay) * CDouble(NSEC_PER_SEC))\r\n    let killTime = DispatchTime.now() + Double(killTimeOffset) / Double(NSEC_PER_SEC)\r\n    (callbackQueue ?? DispatchQueue.main).asyncAfter(deadline: killTime) {\r\n        stub()\r\n    }\r\n```\r\n\r\nBut subclassing doesn't _feel_ right, given that Moya 9.0 deprecated the old `RxMoyaProvider` in favor of extension methods, so maybe I should be only extending as well. Also I have problems even for getting to a compilable version when subclassing `MoyaProvider` without having to add more code than just the only method I'd like to override, but that's a side subject that we can move to a whole new issue if desired 😃 \r\n\r\n▶️ **Question:**\r\nSo is there a way to use `TestScheduler` to delay (in virtual time) responses when using stubs?\r\n\r\nIf not, then I'm willing to help with this because RxTest is a must to me, just please let me know your constraints for this implementation so I can start thinking about an architecture that doesn't break your purposes. For example, possibly #1502 would change how to address this (for better or for worse, I don't know right now).\r\n\r\nThank you very much!"}}
{"actor":{"display_login":"SD10"}}