{"action":"closed","issue":{"url":"https://api.github.com/repos/ninject/Ninject.MockingKernel/issues/26","repository_url":"https://api.github.com/repos/ninject/Ninject.MockingKernel","labels_url":"https://api.github.com/repos/ninject/Ninject.MockingKernel/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/ninject/Ninject.MockingKernel/issues/26/comments","events_url":"https://api.github.com/repos/ninject/Ninject.MockingKernel/issues/26/events","html_url":"https://github.com/ninject/Ninject.MockingKernel/issues/26","id":113185408,"number":26,"title":"Test passes with StandardKernel, but Fails With MockingKernel","user":{"login":"gfeld","id":7225738,"avatar_url":"https://avatars2.githubusercontent.com/u/7225738?v=4","gravatar_id":"","url":"https://api.github.com/users/gfeld","html_url":"https://github.com/gfeld","followers_url":"https://api.github.com/users/gfeld/followers","following_url":"https://api.github.com/users/gfeld/following{/other_user}","gists_url":"https://api.github.com/users/gfeld/gists{/gist_id}","starred_url":"https://api.github.com/users/gfeld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfeld/subscriptions","organizations_url":"https://api.github.com/users/gfeld/orgs","repos_url":"https://api.github.com/users/gfeld/repos","events_url":"https://api.github.com/users/gfeld/events{/privacy}","received_events_url":"https://api.github.com/users/gfeld/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"scott-xu","id":1913505,"avatar_url":"https://avatars2.githubusercontent.com/u/1913505?v=4","gravatar_id":"","url":"https://api.github.com/users/scott-xu","html_url":"https://github.com/scott-xu","followers_url":"https://api.github.com/users/scott-xu/followers","following_url":"https://api.github.com/users/scott-xu/following{/other_user}","gists_url":"https://api.github.com/users/scott-xu/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-xu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-xu/subscriptions","organizations_url":"https://api.github.com/users/scott-xu/orgs","repos_url":"https://api.github.com/users/scott-xu/repos","events_url":"https://api.github.com/users/scott-xu/events{/privacy}","received_events_url":"https://api.github.com/users/scott-xu/received_events","type":"User","site_admin":false},"assignees":[{"login":"scott-xu","id":1913505,"avatar_url":"https://avatars2.githubusercontent.com/u/1913505?v=4","gravatar_id":"","url":"https://api.github.com/users/scott-xu","html_url":"https://github.com/scott-xu","followers_url":"https://api.github.com/users/scott-xu/followers","following_url":"https://api.github.com/users/scott-xu/following{/other_user}","gists_url":"https://api.github.com/users/scott-xu/gists{/gist_id}","starred_url":"https://api.github.com/users/scott-xu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scott-xu/subscriptions","organizations_url":"https://api.github.com/users/scott-xu/orgs","repos_url":"https://api.github.com/users/scott-xu/repos","events_url":"https://api.github.com/users/scott-xu/events{/privacy}","received_events_url":"https://api.github.com/users/scott-xu/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2015-10-24T21:59:44Z","updated_at":"2017-10-28T16:00:36Z","closed_at":"2017-10-28T16:00:36Z","author_association":"NONE","body":"In the following example the test passes when using StandardKernel and fails with MoqMockingKernel  \n    namespace ClassLibrary4\n    {\n        using Ninject;\n        using Ninject.MockingKernel.Moq;\n        using System;\n        using Xunit;\n\n```\n    public class Foo\n    {\n        public Foo([Target1]Bar bar1, [Target2]Bar bar2)\n        {\n            this.bar1 = bar1;\n            this.bar2 = bar2;\n        }\n\n        public Bar bar1 { get; private set; }\n        public Bar bar2 { get; private set; }\n    }\n\n    public class Bar\n    {\n        public Bar(IZed zed) { this.zed = zed; }\n        public IZed zed { get; private set; }\n    }\n\n    public interface IZed { }\n\n    public class Zed1 : IZed { }\n\n    public class Zed2 : IZed { }\n\n    public class Target1 : Attribute { }\n    public class Target2 : Attribute { }\n\n    public class Tests\n    {\n        [Fact]\n        public void Pass()\n        {\n            var kernel = new StandardKernel();\n            kernel.Bind<IZed>().To<Zed1>().WhenAnyAncestorMatches(r => r.Request.Target?.IsDefined(typeof(Target1), true) ?? false);\n            kernel.Bind<IZed>().To<Zed2>().WhenAnyAncestorMatches(r => r.Request.Target?.IsDefined(typeof(Target2), true) ?? false);\n\n            var foo = kernel.Get<Foo>();\n            Assert.IsType<Zed1>(foo.bar1.zed);\n            Assert.IsType<Zed2>(foo.bar2.zed);\n        }\n\n        [Fact]\n        public void Fail()\n        {\n            var kernel = new MoqMockingKernel();\n            kernel.Bind<IZed>().To<Zed1>().WhenAnyAncestorMatches(r => r.Request.Target?.IsDefined(typeof(Target1), true) ?? false);\n            kernel.Bind<IZed>().To<Zed2>().WhenAnyAncestorMatches(r => r.Request.Target?.IsDefined(typeof(Target2), true) ?? false);\n\n            var foo = kernel.Get<Foo>();\n            Assert.IsType<Zed1>(foo.bar1.zed);\n            Assert.IsType<Zed2>(foo.bar2.zed);\n        }\n    }\n}\n```\n"}}
{"actor":{"display_login":"scott-xu"}}