{"action":"created","issue":{"url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/407","repository_url":"https://api.github.com/repos/nsubstitute/NSubstitute","labels_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/407/labels{/name}","comments_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/407/comments","events_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/407/events","html_url":"https://github.com/nsubstitute/NSubstitute/issues/407","id":329135898,"node_id":"MDU6SXNzdWUzMjkxMzU4OTg=","number":407,"title":"Add overload for AndDoes that supports Callback like When...Do","user":{"login":"gtbuchanan","id":715687,"node_id":"MDQ6VXNlcjcxNTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/715687?v=4","gravatar_id":"","url":"https://api.github.com/users/gtbuchanan","html_url":"https://github.com/gtbuchanan","followers_url":"https://api.github.com/users/gtbuchanan/followers","following_url":"https://api.github.com/users/gtbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/gtbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/gtbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtbuchanan/subscriptions","organizations_url":"https://api.github.com/users/gtbuchanan/orgs","repos_url":"https://api.github.com/users/gtbuchanan/repos","events_url":"https://api.github.com/users/gtbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/gtbuchanan/received_events","type":"User","site_admin":false},"labels":[{"id":712764818,"node_id":"MDU6TGFiZWw3MTI3NjQ4MTg=","url":"https://api.github.com/repos/nsubstitute/NSubstitute/labels/feature-request","name":"feature-request","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-04T16:47:58Z","updated_at":"2018-06-05T15:12:37Z","closed_at":null,"author_association":"NONE","body":"Right now, there doesn't seem to be support for complex callbacks with `AndDoes` like there is with `When...Do`. This leads to some redundant code if you want to configure specific callbacks with multiple return results.\r\n\r\nExample:\r\n\r\n```\r\nvar sut = Substitute.For<DbDataReader>();\r\nsut.ReadAsync(Arg.Any<CancellationToken>()).Returns(true, true, true, false);\r\nsut.When(r => r.ReadAsync(Arg.Any<CancellationToken>()))\r\n    .Do(Callback.First(_ => /* Do something only on the first call */));\r\n```\r\n\r\nIt would be great to have an overload of `AndDoes` that supports `Callback` so things like this could be simplified to:\r\n\r\n```\r\nsut.ReadAsync(Arg.Any<CancellationToken>())\r\n    .Returns(true, true, true, false);\r\n    .AndDoes(Callback.First(_ => /* Do something only on the first call */));\r\n```"},"comment":{"url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/comments/394747340","html_url":"https://github.com/nsubstitute/NSubstitute/issues/407#issuecomment-394747340","issue_url":"https://api.github.com/repos/nsubstitute/NSubstitute/issues/407","id":394747340,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDc0NzM0MA==","user":{"login":"gtbuchanan","id":715687,"node_id":"MDQ6VXNlcjcxNTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/715687?v=4","gravatar_id":"","url":"https://api.github.com/users/gtbuchanan","html_url":"https://github.com/gtbuchanan","followers_url":"https://api.github.com/users/gtbuchanan/followers","following_url":"https://api.github.com/users/gtbuchanan/following{/other_user}","gists_url":"https://api.github.com/users/gtbuchanan/gists{/gist_id}","starred_url":"https://api.github.com/users/gtbuchanan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtbuchanan/subscriptions","organizations_url":"https://api.github.com/users/gtbuchanan/orgs","repos_url":"https://api.github.com/users/gtbuchanan/repos","events_url":"https://api.github.com/users/gtbuchanan/events{/privacy}","received_events_url":"https://api.github.com/users/gtbuchanan/received_events","type":"User","site_admin":false},"created_at":"2018-06-05T15:12:37Z","updated_at":"2018-06-05T15:12:37Z","author_association":"NONE","body":"It would cover my example, but I find it semantically awkward. Now it's passing 4 lambdas even though 3 are static values. It wouldn't cover `Callback.First(...).ThenKeepDoing(...)` very well as you'd have to repeat the second action in every subsequent delegate, which would end up more messy than a separate `When...Do(Callback)`.\r\n\r\nI don't think a new builder would be necessary since `Callback` already exists. Plus, it just feels wrong to me to perform a side-effect in the `Returns` method anyway. I do use the delegate-style `Returns` when I have to return a value based on the `CallInfo`, but I still like the idea of a new overload of `AndDoes` to mirror the `Do(Callback)` overload."}}
{"actor":{"display_login":"gtbuchanan"}}