It looks to me like there is something missing here ... The implementation you have shown for Register is different to that which is being called in your test
your implementation : Register(Type contractType, Type concreteType) being called in test : Register<T>(T type) so I'm not sure about this. Secondly, you are passing your interface in to Register as the concrete type, I think this is why you are getting the exception, IProfileRepository mockProfileRepository = mocks.StrictMock<IProfileRepository>(); mockProfileRepository.GetType() will (I believe) return typeof(IProfileRepository) I've been wrong before ;o) On Feb 11, 8:34 pm, Stan B <[email protected]> wrote: > Why doesn't a mock or stub have default constructor? > > I create a mock: > > IProfileRepository mockProfileRepository = > mocks.StrictMock<IProfileRepository>(); > > and then swap in my service locator class: > > serviceLocator.Register<IProfileRepository>(mockProfileRepository.GetType()); > > Register does this: > > public void Register(Type contractType, Type concreteType) > { > lock ( lockObject ) > { > if ( instance.typeMappings.ContainsKey(contractType) ) > { > instance.typeMappings.Remove(contractType); > } > instance.typeMappings.Add(contractType, concreteType); > } > } > > and it blows up with "No parameterless constructor defined for this > object" > > I can't figure out why.... -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
