0
考虑下面的流线型例如,使用RhinoMocks和MSpec:如何在返回之前修改模拟对象上方法调用的结果?
[Subject(typeof (LocationController))]
public class when_creating_a_location_with_invalid_model : context_for_location_controller
{
static LocationModel model = new LocationModel();
static SelectList states = new SelectList(new Dictionary<string,string> {
{ "IN", "Indiana" }, { "NY", "New York" }
});
static ActionResult result;
Establish context =() =>
{
LocationModelBuilder.Stub(x =>
x.Build(Arg<LocationModel>.Is.Equal(model))).Return(model);
}
Because of =() => result = subject.Create(model);
It should_automatically_select_a_state =() => result.Model<LocationModel>()
.States.ShouldNotBeEmpty();
}
如何修改包含在模型变量对象是从LocationModelBuilder.Build()的存根调用返回前?我想在Build()返回之前执行model.States = states
之类的任务。我尝试使用Do()处理程序,但我放弃了...
This Works,thanks! – 2011-02-25 13:39:05