I've started using RhinoAutoMocker and I was wondering if someone could give me hand with a problem I'm facing. I've got the following constructor (exposed by the object I want to test):
public class MyViewModel{
public MyViewModel(ICommand cmd1, ICommand cmd2){
}
}
Each command fires an event which is responsible for doing a different operation. Before using RhinoAutoMocker, I could simply create different mocks and that would allowed me to control the actions run by my view model. Now that I'm trying to update my code to RhinoAutoMocker, it will try to use the same object for both parameters. I'm assuming that there's a simple way to solve this, but I don't know how. Can anyone give me hand?
Thanks.
I managed to solve this problem by changing the default configuration before setting the stubs and accessing the class under test:
[TestFixture]
public class BoletimViewModelApresentaDlgPdf {
[Test]
public void Test() {
var geraRelatorioCmd = MockRepository.GenerateStub<ICommand>();
var autoMocker = new RhinoAutoMocker<BoletimViewModel>();
autoMocker.Container.Configure(
conf => {
conf.For<BoletimViewModel>()
.Use<BoletimViewModel>()
.Ctor<ICommand>("geraRelatorio").Is(geraRelatorioCmd);
}
);
autoMocker.ClassUnderTest.GeraRelatorio
.Raise( cmd => cmd.CommandExecuted += null,
autoMocker.ClassUnderTest.GeraRelatorio,
new CommandParameterEventArgs(new object() ));
autoMocker.Get<IVisualizadorBoletim>()
.AssertWasCalled( v => v.VisualizaBoletim(
Arg<IEnumerable<DadosHorticulas>>.Is.Anything,
Arg<DateTime>.Is.Anything,
Arg<DateTime>.Is.Anything));
}
}