KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using Ninject.Extensions.Factory with Ninject 3 to create a factory, which creates different types of IFoo based on the string provided to the factory. I've got a passing unit test, but oddly, only in the Resharper test runner. In the NCrunch test runner it fails. Is this a NCrunch config issue, or do I need to change the code? The interface: public interface IFooFactory { IFoo CreateFoo(string name); } The Ninject bindings: kernel.Bind<IFooFactory>().ToFactory(() => new UseFirstParameterAsNameInstanceProvider()); kernel.Bind<IFoo>().To<BarFoo>().Named("Bar"); The test: [Test] public void CanCreateFooTest() { var factory = (IFooFactory) Kernel.GetService(typeof(IFooFactory)); var bar = factory.CreateFoo("Bar"); Assert.AreEqual(typeof(BarFoo), bar.GetType()); } And the NCrunch exception: System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> Ninject.ActivationException : Error activating IInterceptor using conditional implicit self-binding of IInterceptor Provider returned null. Activation path: 2) Injection of dependency IInterceptor into parameter of constructor of type IFooFactoryProxy 1) Request for IFooFactory Suggestions: 1) Ensure that the provider handles creation requests properly. at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVi
Tags (comma-separated)
Save Edits
Cancel