単体テストに RhinoMock を使用していますが、特定のメソッドがパラメーターとして受け取った同じオブジェクトを常に返すように設定する方法を知りたいです。
これは私がモックしたいインターフェースです:
public interface IItemRepository
{
Item Craete(Item item);
}
Create メソッドが呼び出されるたびに、モックされたスタブがパラメーターとして渡された同じオブジェクトを返すように RhinoMocks をセットアップしたいと考えています。
これは私のテスト初期化方法です:
[TestInitialize]
public void CrateServiceWithMockRepository()
{
var stubRepository = MockRepository.GenerateStub<IItemRepository>();
// ... how to set-up the stubRepository as described above ...
// Create the target service for this unit test
this.targetService = new ServiceXYZ(stubRepository);
}