我设法通过在设置存根和访问被测类之前更改默认配置来解决这个问题:
[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));
}
}