{"action":"created","comment":{"url":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments/56157336","id":56157336,"diff_hunk":"@@ -0,0 +1,97 @@\n+﻿namespace NServiceBus.AcceptanceTests.Pipeline\n+{\n+    using System;\n+    using System.Threading.Tasks;\n+    using NServiceBus.AcceptanceTesting;\n+    using EndpointTemplates;\n+    using NServiceBus.Pipeline;\n+    using NUnit.Framework;\n+\n+    public class When_replacing_behavior : NServiceBusAcceptanceTest\n+    {\n+        [Test]\n+        public async Task Should_invoke_replacement_in_pipeline()\n+        {\n+            var context = await Scenario.Define<Context>()\n+                .WithEndpoint<EndpointWithReplacement>(e => e\n+                    .When(s => s.SendLocal<Message>(m => { })))\n+                .Done(c => c.MessageHandled)\n+                .Run();\n+\n+            Assert.IsFalse(context.OriginalBehaviorInvoked);\n+            Assert.IsTrue(context.ReplacementBehaviorInvoked);\n+        }\n+\n+        class Context : ScenarioContext\n+        {\n+            public bool OriginalBehaviorInvoked { get; set; }\n+            public bool ReplacementBehaviorInvoked { get; set; }\n+\n+            public bool MessageHandled { get; set; }\n+        }\n+\n+        class OriginalBehavior : Behavior<ITransportReceiveContext>\n+        {\n+            Context testContext;\n+\n+            public OriginalBehavior(Context testContext)\n+            {\n+                this.testContext = testContext;\n+            }\n+\n+            public override Task Invoke(ITransportReceiveContext context, Func<Task> next)\n+            {\n+                testContext.OriginalBehaviorInvoked = true;\n+                return next();\n+            }\n+        }\n+\n+        class ReplacementBehavior : Behavior<ITransportReceiveContext>\n+        {\n+            Context testContext;\n+\n+            public ReplacementBehavior(Context testContext)\n+            {\n+                this.testContext = testContext;\n+            }\n+\n+            public override Task Invoke(ITransportReceiveContext context, Func<Task> next)\n+            {\n+                testContext.ReplacementBehaviorInvoked = true;\n+                return next();\n+            }\n+        }\n+\n+        class EndpointWithReplacement : EndpointConfigurationBuilder\n+        {\n+            public EndpointWithReplacement()\n+            {\n+                EndpointSetup<DefaultServer>(c =>\n+                {\n+                    c.Pipeline.Replace(\"demoBehavior\", typeof(ReplacementBehavior));\n+                    c.Pipeline.Register(\"demoBehavior\", typeof(OriginalBehavior), \"test behavior replacement\");","path":"src/NServiceBus.AcceptanceTests/Pipeline/When_replacing_behavior.cs","position":72,"original_position":72,"commit_id":"daf1f670d2166b6f2bf6a0a4ccdaf605196bc783","original_commit_id":"daf1f670d2166b6f2bf6a0a4ccdaf605196bc783","user":{"login":"timbussmann","id":3524870,"avatar_url":"https://avatars.githubusercontent.com/u/3524870?v=3","gravatar_id":"","url":"https://api.github.com/users/timbussmann","html_url":"https://github.com/timbussmann","followers_url":"https://api.github.com/users/timbussmann/followers","following_url":"https://api.github.com/users/timbussmann/following{/other_user}","gists_url":"https://api.github.com/users/timbussmann/gists{/gist_id}","starred_url":"https://api.github.com/users/timbussmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timbussmann/subscriptions","organizations_url":"https://api.github.com/users/timbussmann/orgs","repos_url":"https://api.github.com/users/timbussmann/repos","events_url":"https://api.github.com/users/timbussmann/events{/privacy}","received_events_url":"https://api.github.com/users/timbussmann/received_events","type":"User","site_admin":false},"body":"I did it intentionally to make sure replace works out of order (because of feature activation which also may run out of order).  Are you ok if I add a comment about this instead?","created_at":"2016-03-15T12:56:26Z","updated_at":"2016-03-15T12:56:26Z","html_url":"https://github.com/Particular/NServiceBus/pull/3579#discussion_r56157336","pull_request_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579","_links":{"self":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments/56157336"},"html":{"href":"https://github.com/Particular/NServiceBus/pull/3579#discussion_r56157336"},"pull_request":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579"}}},"pull_request":{"url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579","id":62561258,"html_url":"https://github.com/Particular/NServiceBus/pull/3579","diff_url":"https://github.com/Particular/NServiceBus/pull/3579.diff","patch_url":"https://github.com/Particular/NServiceBus/pull/3579.patch","issue_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3579","number":3579,"state":"open","locked":false,"title":"Fix replacing behaviors","user":{"login":"timbussmann","id":3524870,"avatar_url":"https://avatars.githubusercontent.com/u/3524870?v=3","gravatar_id":"","url":"https://api.github.com/users/timbussmann","html_url":"https://github.com/timbussmann","followers_url":"https://api.github.com/users/timbussmann/followers","following_url":"https://api.github.com/users/timbussmann/following{/other_user}","gists_url":"https://api.github.com/users/timbussmann/gists{/gist_id}","starred_url":"https://api.github.com/users/timbussmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timbussmann/subscriptions","organizations_url":"https://api.github.com/users/timbussmann/orgs","repos_url":"https://api.github.com/users/timbussmann/repos","events_url":"https://api.github.com/users/timbussmann/events{/privacy}","received_events_url":"https://api.github.com/users/timbussmann/received_events","type":"User","site_admin":false},"body":"fixes #3574 \r\n\r\nWhen replacing behaviors it didn't replace the behavior factory method of the original behavior registration. When the RegisterStep should create the instance of the behavior, it would fallback to the original factory instead of resolving the new behavior.\r\n\r\n* Replacing factory method on `RegisterStep` properly\r\n* Allowing Replacements to define a behavior instance or a behavior factory the same way as `pipeline.Register` does\r\n* Added an acceptance test\r\n\r\n@Particular/nservicebus-maintainers @indualagarsamy please review","created_at":"2016-03-11T15:47:57Z","updated_at":"2016-03-15T12:56:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"165e242192928cc641066bdc0309ff2409ab0175","assignee":{"login":"timbussmann","id":3524870,"avatar_url":"https://avatars.githubusercontent.com/u/3524870?v=3","gravatar_id":"","url":"https://api.github.com/users/timbussmann","html_url":"https://github.com/timbussmann","followers_url":"https://api.github.com/users/timbussmann/followers","following_url":"https://api.github.com/users/timbussmann/following{/other_user}","gists_url":"https://api.github.com/users/timbussmann/gists{/gist_id}","starred_url":"https://api.github.com/users/timbussmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timbussmann/subscriptions","organizations_url":"https://api.github.com/users/timbussmann/orgs","repos_url":"https://api.github.com/users/timbussmann/repos","events_url":"https://api.github.com/users/timbussmann/events{/privacy}","received_events_url":"https://api.github.com/users/timbussmann/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579/commits","review_comments_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579/comments","review_comment_url":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/issues/3579/comments","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/daf1f670d2166b6f2bf6a0a4ccdaf605196bc783","head":{"label":"Particular:replacing-behaviors","ref":"replacing-behaviors","sha":"daf1f670d2166b6f2bf6a0a4ccdaf605196bc783","user":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"repo":{"id":1056713,"name":"NServiceBus","full_name":"Particular/NServiceBus","owner":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Particular/NServiceBus","description":"The most popular service bus for .NET","fork":false,"url":"https://api.github.com/repos/Particular/NServiceBus","forks_url":"https://api.github.com/repos/Particular/NServiceBus/forks","keys_url":"https://api.github.com/repos/Particular/NServiceBus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Particular/NServiceBus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Particular/NServiceBus/teams","hooks_url":"https://api.github.com/repos/Particular/NServiceBus/hooks","issue_events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/events{/number}","events_url":"https://api.github.com/repos/Particular/NServiceBus/events","assignees_url":"https://api.github.com/repos/Particular/NServiceBus/assignees{/user}","branches_url":"https://api.github.com/repos/Particular/NServiceBus/branches{/branch}","tags_url":"https://api.github.com/repos/Particular/NServiceBus/tags","blobs_url":"https://api.github.com/repos/Particular/NServiceBus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Particular/NServiceBus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Particular/NServiceBus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Particular/NServiceBus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/{sha}","languages_url":"https://api.github.com/repos/Particular/NServiceBus/languages","stargazers_url":"https://api.github.com/repos/Particular/NServiceBus/stargazers","contributors_url":"https://api.github.com/repos/Particular/NServiceBus/contributors","subscribers_url":"https://api.github.com/repos/Particular/NServiceBus/subscribers","subscription_url":"https://api.github.com/repos/Particular/NServiceBus/subscription","commits_url":"https://api.github.com/repos/Particular/NServiceBus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Particular/NServiceBus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Particular/NServiceBus/contents/{+path}","compare_url":"https://api.github.com/repos/Particular/NServiceBus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Particular/NServiceBus/merges","archive_url":"https://api.github.com/repos/Particular/NServiceBus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Particular/NServiceBus/downloads","issues_url":"https://api.github.com/repos/Particular/NServiceBus/issues{/number}","pulls_url":"https://api.github.com/repos/Particular/NServiceBus/pulls{/number}","milestones_url":"https://api.github.com/repos/Particular/NServiceBus/milestones{/number}","notifications_url":"https://api.github.com/repos/Particular/NServiceBus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Particular/NServiceBus/labels{/name}","releases_url":"https://api.github.com/repos/Particular/NServiceBus/releases{/id}","deployments_url":"https://api.github.com/repos/Particular/NServiceBus/deployments","created_at":"2010-11-06T12:54:52Z","updated_at":"2016-03-15T06:56:07Z","pushed_at":"2016-03-15T12:31:57Z","git_url":"git://github.com/Particular/NServiceBus.git","ssh_url":"git@github.com:Particular/NServiceBus.git","clone_url":"https://github.com/Particular/NServiceBus.git","svn_url":"https://github.com/Particular/NServiceBus","homepage":"http://particular.net/nservicebus","size":159906,"stargazers_count":895,"watchers_count":895,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":480,"mirror_url":null,"open_issues_count":252,"forks":480,"open_issues":252,"watchers":895,"default_branch":"develop"}},"base":{"label":"Particular:develop","ref":"develop","sha":"7aadffd7975d04391c77574eba7b9e01f4f4f457","user":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"repo":{"id":1056713,"name":"NServiceBus","full_name":"Particular/NServiceBus","owner":{"login":"Particular","id":5038441,"avatar_url":"https://avatars.githubusercontent.com/u/5038441?v=3","gravatar_id":"","url":"https://api.github.com/users/Particular","html_url":"https://github.com/Particular","followers_url":"https://api.github.com/users/Particular/followers","following_url":"https://api.github.com/users/Particular/following{/other_user}","gists_url":"https://api.github.com/users/Particular/gists{/gist_id}","starred_url":"https://api.github.com/users/Particular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Particular/subscriptions","organizations_url":"https://api.github.com/users/Particular/orgs","repos_url":"https://api.github.com/users/Particular/repos","events_url":"https://api.github.com/users/Particular/events{/privacy}","received_events_url":"https://api.github.com/users/Particular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Particular/NServiceBus","description":"The most popular service bus for .NET","fork":false,"url":"https://api.github.com/repos/Particular/NServiceBus","forks_url":"https://api.github.com/repos/Particular/NServiceBus/forks","keys_url":"https://api.github.com/repos/Particular/NServiceBus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Particular/NServiceBus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Particular/NServiceBus/teams","hooks_url":"https://api.github.com/repos/Particular/NServiceBus/hooks","issue_events_url":"https://api.github.com/repos/Particular/NServiceBus/issues/events{/number}","events_url":"https://api.github.com/repos/Particular/NServiceBus/events","assignees_url":"https://api.github.com/repos/Particular/NServiceBus/assignees{/user}","branches_url":"https://api.github.com/repos/Particular/NServiceBus/branches{/branch}","tags_url":"https://api.github.com/repos/Particular/NServiceBus/tags","blobs_url":"https://api.github.com/repos/Particular/NServiceBus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Particular/NServiceBus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Particular/NServiceBus/git/refs{/sha}","trees_url":"https://api.github.com/repos/Particular/NServiceBus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Particular/NServiceBus/statuses/{sha}","languages_url":"https://api.github.com/repos/Particular/NServiceBus/languages","stargazers_url":"https://api.github.com/repos/Particular/NServiceBus/stargazers","contributors_url":"https://api.github.com/repos/Particular/NServiceBus/contributors","subscribers_url":"https://api.github.com/repos/Particular/NServiceBus/subscribers","subscription_url":"https://api.github.com/repos/Particular/NServiceBus/subscription","commits_url":"https://api.github.com/repos/Particular/NServiceBus/commits{/sha}","git_commits_url":"https://api.github.com/repos/Particular/NServiceBus/git/commits{/sha}","comments_url":"https://api.github.com/repos/Particular/NServiceBus/comments{/number}","issue_comment_url":"https://api.github.com/repos/Particular/NServiceBus/issues/comments{/number}","contents_url":"https://api.github.com/repos/Particular/NServiceBus/contents/{+path}","compare_url":"https://api.github.com/repos/Particular/NServiceBus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Particular/NServiceBus/merges","archive_url":"https://api.github.com/repos/Particular/NServiceBus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Particular/NServiceBus/downloads","issues_url":"https://api.github.com/repos/Particular/NServiceBus/issues{/number}","pulls_url":"https://api.github.com/repos/Particular/NServiceBus/pulls{/number}","milestones_url":"https://api.github.com/repos/Particular/NServiceBus/milestones{/number}","notifications_url":"https://api.github.com/repos/Particular/NServiceBus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Particular/NServiceBus/labels{/name}","releases_url":"https://api.github.com/repos/Particular/NServiceBus/releases{/id}","deployments_url":"https://api.github.com/repos/Particular/NServiceBus/deployments","created_at":"2010-11-06T12:54:52Z","updated_at":"2016-03-15T06:56:07Z","pushed_at":"2016-03-15T12:31:57Z","git_url":"git://github.com/Particular/NServiceBus.git","ssh_url":"git@github.com:Particular/NServiceBus.git","clone_url":"https://github.com/Particular/NServiceBus.git","svn_url":"https://github.com/Particular/NServiceBus","homepage":"http://particular.net/nservicebus","size":159906,"stargazers_count":895,"watchers_count":895,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":480,"mirror_url":null,"open_issues_count":252,"forks":480,"open_issues":252,"watchers":895,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579"},"html":{"href":"https://github.com/Particular/NServiceBus/pull/3579"},"issue":{"href":"https://api.github.com/repos/Particular/NServiceBus/issues/3579"},"comments":{"href":"https://api.github.com/repos/Particular/NServiceBus/issues/3579/comments"},"review_comments":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579/comments"},"review_comment":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Particular/NServiceBus/pulls/3579/commits"},"statuses":{"href":"https://api.github.com/repos/Particular/NServiceBus/statuses/daf1f670d2166b6f2bf6a0a4ccdaf605196bc783"}}}}