开发者

Saving to a repository using Rhino Mocks

I have so far been coding by doing mostly Get methods in my business/service layer using Rhino Mocks to get an expected List or type and making Rhino Mocks return it for me, my question is how do I test a set/save call, e.g void SaveCustomers(Customer)

I have a call called GetCustomers, can I use Rhino mocks to call this immediately after my SaveCustomers call to see if it saved it into memory? I have tried this my mocking my repo and calling it but it returns a null, what is the correct syntax? I can开发者_JAVA技巧't find an example using StrictMock or GenerateStub.

Thanks!


If you're talking about using Rhino Mocks to mock the repository, you wouldn't need to get it to call GetCustomers, you can check it directly using syntax like this (using the 'AAA' style):

IMyRepository repository = MockRepository.GenerateMock<IMyRepository>();
// do stuff with repository
repository.AssertWasCalled(x => x.SaveCustomers(myTestCustomer));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜