You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following error occurs when resolving the interface IADUtilities:
The type X.Business.Utilities.ADUtilitiesStubbed is not interceptable.
Parameter name: interceptedType
Exception occurred while:
·resolving type: 'ADUtilitiesStubbed'
•resolving type: 'IADUtilities' mapped to 'ADUtilitiesStubbed'
My setup:
public interface IAdUtilities {}
public class AdUtilities : IAdUtilities {}
public class AdUtilitiesStubbed : IAdUtilities {}
The registrations are build like: 1. Registration by convention:
var assemblies = System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, AssemblyConstants.AssemblyNamePrefix + "*.dll")
.Select(f => System.Reflection.Assembly.LoadFile(f));
container.RegisterTypes(
AllClasses.FromAssemblies(assemblies).Where(t => t.Namespace.StartsWith(AssemblyConstants.AssemblyNamePrefix, StringComparison.OrdinalIgnoreCase)),
WithMappings.FromMatchingInterface,
WithName.Default,
t => lifetimeManager());
Result of this:
IAdUtilities is registered to AdUtilities and resolvable
AdUtilitiesStubbed is registered to itself and resolvable
2. Overwrite convention registrations by more advanced registration
container.RegisterType<IADUtilities, ADUtilities>(
createLifetimeManager(),
new Interceptor<InterfaceInterceptor>(),
new InterceptionBehavior<LogBehavior>(),
new InterceptionBehavior(new ImpersonationBehavior("mydomain", "myUsername", "myPassword", container.Resolve<Interfaces.ILogger>()))
);
Result of this:
IAdUtilities is registered to AdUtilities with 2 interceptors, and is resolvable
AdUtilitiesStubbed is not changed but is not resolvable anymore:
The type X.Business.Utilities.ADUtilitiesStubbed is not interceptable.
Parameter name: interceptedType
Exception occurred while:
·resolving type: 'ADUtilitiesStubbed'
This is probably caused by the fact that interception is registered on the FromType (here IAdUtilities).
3. For unit testing, the standard registrations should be overwritten by stubbed classes container.RegisterType<Business.Interfaces.Utilities.IADUtilities, Business.Utilities.ADUtilitiesStubbed>(createLifetimeManager());
Result of this:
IAdUtilities is registered to AdUtilitiesStubbed, resolving fails:
The type X.Business.Utilities.ADUtilitiesStubbed is not interceptable.
Parameter name: interceptedType
Exception occurred while:
·resolving type: 'ADUtilitiesStubbed'
•resolving type: 'IADUtilities' mapped to 'ADUtilitiesStubbed'
It seems like the resolve happens in 2 steps:
IAdUtilities -> AdUtilitiesStubbed
AdUtilitiesStubbed -> AdUtilitiesStubbed (which fails to resolve)
Why does resolving the Stubbed class fail? This is not as expected (in old unity versions this works correct).
Can this be fixed please?
fyi: When reregistereing AdUtilitiesStubbed as last, resolve succeeds: container.RegisterType<Business.Utilities.ADUtilitiesStubbed, Business.Utilities.ADUtilitiesStubbed>(createLifetimeManager());
The text was updated successfully, but these errors were encountered:
Hi,
The following error occurs when resolving the interface IADUtilities:
My setup:
The registrations are build like:
1. Registration by convention:
Result of this:
2. Overwrite convention registrations by more advanced registration
Result of this:
This is probably caused by the fact that interception is registered on the FromType (here IAdUtilities).
3. For unit testing, the standard registrations should be overwritten by stubbed classes
container.RegisterType<Business.Interfaces.Utilities.IADUtilities, Business.Utilities.ADUtilitiesStubbed>(createLifetimeManager());
Result of this:
It seems like the resolve happens in 2 steps:
Why does resolving the Stubbed class fail? This is not as expected (in old unity versions this works correct).
Can this be fixed please?
fyi: When reregistereing AdUtilitiesStubbed as last, resolve succeeds:
container.RegisterType<Business.Utilities.ADUtilitiesStubbed, Business.Utilities.ADUtilitiesStubbed>(createLifetimeManager());
The text was updated successfully, but these errors were encountered: