I'm a little new to Unity and dependency. I am trying to write a unit test that looks something like this:
[Test] public void Test() { UnityContainer container = new UnityContainer(); DynamicMock myMock = new DynamicMock(typeof(IMyInterface)); container.RegisterInstance(typeof(IMyInterface), myMock.MockInstance);
When this test runs, the container throws an ArgumentNullException inside the RegisterInstance method with the message Value cannot be null. Parameter name: assignmentValueType. Value cannot be null. Parameter name: assignmentValueType.
Top stack trace line at Microsoft.Practices.Unity.Utility.Guard.TypeIsAssignable(Type assignmentTargetType, Type assignmentValueType, String argumentName) .
Why can't I register MockInstance with UnityContainer and how do I get around this?
dependency-injection ioc-container nunit mocking unity-container
Phil
source share