I am trying to use the MoqAutoMocker class that comes with StructureMap and I cannot find examples of how to use it. All I need is an example on the StructureMap website that uses RhinoMocks .
What I'm trying to do is get a link to one of my dependencies with automatic bullying / injection using the Get method. According to this link above, I would have to do something like this
autoMocker.Get<IMockedService>().AssertWasCalled(s => s.Go());
Notice how you can use AssertWasCalled, which distorts that the Get function returns a reference to the RhinoMocks Mock object? The same bit of code does not work for me when I use MoqAutoMocker.
I have a SignInController class that depends on the ISecurityService in the constructor. Using MoqAutoMocker, like RhinoAutoMocker, is used in this example, I think I should do this ...
var autoMocker = new MoqAutoMocker<SignInController>();
autoMocker.Get<ISecurityService>().Setup(ss => ss.ValidateLogin
(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
But the problem is that I never get access to the installation method. In this case, calling autoMocker.Get seems to return an ISecurityService instance, not a Mock <ISecurityService>
Has anyone successfully used MoqAutoMocker in this way? Am I just doing it wrong?
source
share