RegisterType doesn't work with string, int, or the other CLR primitive types, because you can't legally say "new string()". You can use RegisterInstance:
And then anywhere you've got a dependency of type string, that string will be injected. But that's also probably not what you want to do, since a connection string is different from a file name is different from a user name, but they're all of type string.
What you need to do is, in your RegisterType call, specify which constructor you want, and what the value of the string will be. You use it by passing an InjectionConstructor object to RegisterType. If you want to use the default constructor instead of the
one that takes a string, do this:
container.RegisterType<IMockUnityStringTarget, MockUnityStringTarget>(new InjectionConstructor());
That says "Use the constructor for MockUnityStringTarget that takes zero arguments."
If you want to use the one that takes a string, do this:
container.RegisterType<IMockUnityStringTarget, MockUnityStringTarget>(new InjectionConstructor("whatever string I want"));
You can also pass InjectionProperty objects to specify which properties to inject, or InjectionMethod to specify which methods to call.
By default, if you don't specify this, the container will look for the constructor with the most arguments, and attempt to create instances to pass as each one. Unfortunately, we can't just randomly new up a string, so in the case of primitives you need
to be a little more explicit.
Hope this helps,