Alex Rivera | Logout

How do I combine two interfaces when creating mocks?

Asked 2009-01-29T13:41:32.140
18

We are using Rhino Mocks to perform some unit testing and need to mock two interfaces. Only one interface is implemented on the object and the other is implemented dynamically using an aspect-oriented approach. Is there an easy way to combine the two interfaces dynamically so that a mock can be created and the methods stubbed for both interfaces?

Edit
Report

1 Answer

18

Using Rhino Mocks

var mock = MockRepository.GenerateMock<IFirst, ISecond>();
mock.Stub(m => m.FirstProperty).PropertyBehavior();
((ISecond)mock).Stub(k=> k.SecondProperty).PropertyBehavior();

Found and used the information from http://www.richard-banks.org/2010/08/mocking-comparison-part-11-multiple.html

answered 2012-12-14T21:48:37.593

Your Answer