{"action":"opened","issue":{"url":"https://api.github.com/repos/rbengtsson/Automoqer/issues/4","repository_url":"https://api.github.com/repos/rbengtsson/Automoqer","labels_url":"https://api.github.com/repos/rbengtsson/Automoqer/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/rbengtsson/Automoqer/issues/4/comments","events_url":"https://api.github.com/repos/rbengtsson/Automoqer/issues/4/events","html_url":"https://github.com/rbengtsson/Automoqer/issues/4","id":297563079,"number":4,"title":"improved support for aaa pattern","user":{"login":"manne","id":80180,"avatar_url":"https://avatars3.githubusercontent.com/u/80180?v=4","gravatar_id":"","url":"https://api.github.com/users/manne","html_url":"https://github.com/manne","followers_url":"https://api.github.com/users/manne/followers","following_url":"https://api.github.com/users/manne/following{/other_user}","gists_url":"https://api.github.com/users/manne/gists{/gist_id}","starred_url":"https://api.github.com/users/manne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manne/subscriptions","organizations_url":"https://api.github.com/users/manne/orgs","repos_url":"https://api.github.com/users/manne/repos","events_url":"https://api.github.com/users/manne/events{/privacy}","received_events_url":"https://api.github.com/users/manne/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-15T19:12:44Z","updated_at":"2018-02-15T19:12:44Z","closed_at":null,"author_association":"NONE","body":"I like the [aaa pattern](http://wiki.c2.com/?ArrangeActAssert). automoqer has still room for improvement regarding to support this pattern. To apply the aaa pattern, a comment has to be written before the end of the using block.\r\n\r\n```csharp\r\nvoid Main()\r\n{\r\n\t// Arrange\r\n\tusing(var moqer = new AutoMoqer<EventConsumer>().Build())\r\n\t{\r\n\t\tmoqer.Param<IDependency>().Setup(d => d.Register());\r\n\t\t\r\n\t\t// Act\r\n\t\tmoqer.Param<ICrazyEventEmiter>().Raise(e => e.Foo += null, EventArgs.Empty);\r\n\t\t\r\n\t\t// Assert\r\n\t\t// is done in moqer.Dispose()\r\n\t}\r\n}\r\n\r\npublic class EventConsumer\r\n{\r\n\tpublic EventConsumer(ICrazyEventEmiter eventEmiter, IDependency dependency)\r\n\t{\r\n\t\teventEmiter.Foo += (sender, args) =>\r\n\t\t{\r\n\t\t\tdependency.Register();\r\n\t\t};\r\n\t}\t\r\n}\r\n\r\npublic interface IDependency\r\n{\r\n\tvoid Register();\r\n}\r\n\r\npublic interface ICrazyEventEmiter\r\n{\r\n\tevent EventHandler Foo;\r\n}\r\n\r\n```\r\n\r\nA possibility is to introduce an explicit method to call the verification, like `AutoMoqerContainer<TService>.VerifyAll():void `.  The disadvantage is that the verification is done twice. This can be mitigated by introducing a class which does not implicitly invoke the verification, e.g `AutoMoqerContainerWithExplicitVerification<TService>`.\r\n\r\n@rbengtsson if you want to have this feature, I will send an PR. As always I am opened for suggestions and/or further improvement. Especially in nomenclature 😉 "}}
{"actor":{"display_login":"manne"}}