I have a unit test project with a configuration that contains several Unity registrations like follows.
<register type="IAlpha" mapTo="Alpha" />
Is there a way in code to temporarily override the mapping from IAlpha to Alpha with something like IAlpha to MockAlpha? I want to temporarily divert calls to IAlpha to a mock class for the duration of a unit test then restore the original mapping.
I tried calling the IUnityContainer.RegisterType method at the beginning of the test, but unfortunately the invocation of the method still goes to Alpha instead of MockAlpha. e.g. something like this didn't work since the invocations of IAlpha still
went to Alpha instead of MockAlpha
IUnityContainer unityContainerInstance = new UnityContainer();
unityContainerInstance.RegisterType(typeof(IAlpha), typeof(MockAlpha), new ContainerControlledLifetimeManager());
Disclaimer: There may be slight syntactic errors in my examples since they aren't copy and pastes.
Any help is appreciated.