{"action":"created","issue":{"url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/210","labels_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/210/labels{/name}","comments_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/210/comments","events_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/210/events","html_url":"https://github.com/nsubstitute/NSubstitute/issues/210","id":112817257,"number":210,"title":"Auto-mocking an IObservable pushes a value","user":{"login":"MansVestin","id":3986058,"avatar_url":"https://avatars.githubusercontent.com/u/3986058?v=3","gravatar_id":"","url":"https://api.github.com/users/MansVestin","html_url":"https://github.com/MansVestin","followers_url":"https://api.github.com/users/MansVestin/followers","following_url":"https://api.github.com/users/MansVestin/following{/other_user}","gists_url":"https://api.github.com/users/MansVestin/gists{/gist_id}","starred_url":"https://api.github.com/users/MansVestin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MansVestin/subscriptions","organizations_url":"https://api.github.com/users/MansVestin/orgs","repos_url":"https://api.github.com/users/MansVestin/repos","events_url":"https://api.github.com/users/MansVestin/events{/privacy}","received_events_url":"https://api.github.com/users/MansVestin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-10-22T14:38:42Z","updated_at":"2015-11-19T23:31:50Z","closed_at":null,"body":"When an IObservable<T> is recursively auto-mocked, a default value will be pushed. This does not happen if you create the mock explicitly.\r\nTo me, it doesn't make sense that auto-mocking and explicit mocking gives different behaviour. Also, since my listeners executes code which isn't part of the test, I don't want them to be called - this forces me to mock more stuff.\r\nFakeItEasy does not have this behaviour.\r\n\r\n    public interface IFoo\r\n    {\r\n      IObservable<int> WhenStuffHappened { get; }\r\n    }\r\n\r\n    private void OnStuffHappened_(int e)\r\n    {\r\n      Trace.WriteLine(\"Did not expect to get here\");\r\n    }\r\n\r\n    [Fact]\r\n    public void Test()\r\n    {\r\n      var foo = Substitute.For<IFoo>();\r\n\r\n      // If you uncomment this line, OnStuffHappened_ won't be called\r\n      // foo.WhenStuffHappened.Returns(Substitute.For<IObservable<int>>());\r\n\r\n      // This triggers an unexpected call to OnStuffHappened_:\r\n      foo.WhenStuffHappened.Subscribe(OnStuffHappened_);\r\n    }"},"comment":{"url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/comments/158233658","html_url":"https://github.com/nsubstitute/NSubstitute/issues/210#issuecomment-158233658","issue_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/210","id":158233658,"user":{"login":"paulcbetts","id":1396,"avatar_url":"https://avatars.githubusercontent.com/u/1396?v=3","gravatar_id":"","url":"https://api.github.com/users/paulcbetts","html_url":"https://github.com/paulcbetts","followers_url":"https://api.github.com/users/paulcbetts/followers","following_url":"https://api.github.com/users/paulcbetts/following{/other_user}","gists_url":"https://api.github.com/users/paulcbetts/gists{/gist_id}","starred_url":"https://api.github.com/users/paulcbetts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulcbetts/subscriptions","organizations_url":"https://api.github.com/users/paulcbetts/orgs","repos_url":"https://api.github.com/users/paulcbetts/repos","events_url":"https://api.github.com/users/paulcbetts/events{/privacy}","received_events_url":"https://api.github.com/users/paulcbetts/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T23:31:50Z","updated_at":"2015-11-19T23:31:50Z","body":"Paul from January 2014 continues to be right - IObservable is a special class like Task<T>, because it is often awaited. Awaiting a call that returns Observable.Empty throws. It is very rarely correct to explicitly mock IObservable<T> (just as we would never mock IEnumerable<T>, we'd just substitute in a different value)."}}