I feel like I h开发者_开发知识库ave lost my mind because I am sure I have done this before. Hopefully one of you can point me in the right direction.
Essentially I have an view that I want to test that the presenter is correctly setting the property with a list of objects. Example:
public ComplexDto{
public string name{get;set;}
public string description{get;set;}
}
public interface ITestView{
IList<ComplexDto> dto{get;set;}
}
Within the Presenter it sets a list like:
...
var dtos = new List<ComplexDto>();
dtos.add(new ComplexDto(){name="test name", description="this is some description"}
view.dto = dtos;
...
I need to test that that contents of the list of the dto work.
I have tried GetArgumentsForCallsMadeOn but I think this does not work with properties.
Thanks for any help!
EDIT
This should do it:
var view = MockRepository.GenerateMock<ITestView>();
var dtos = new List<ComplexDto>();
dtos.Add(new ComplexDto() {name = "test name", description = "this is some description"});
List<ComplexDto> passedIn;
view.Expect(v => v.dto).SetPropertyWithArgument(dtos).WhenCalled(mi => passedIn = (List<ComplexDto>) mi.Arguments[0]);
view.dto = dtos;
view.VerifyAllExpectations();
精彩评论