I am looking for ways to make the following more concise.
public class MyTests { IPresenter presenter; [SetUp] public void SetUp() { presenter = MockRepository.GenerateStub<IPresenter>(); } ... }
In particular, specifying the type again when creating the layout seems redundant. For example, I can write it this way and use reflection to get the type and create a stub automatically:
public class MyTests { IPresenter presenter; [SetUp] public void SetUp() { Stub(x => x.presenter); } void Stub(Expression<Func<MyTests, object>> expression) { ... } }
This will work, but the compiler will no longer be able to determine if a leader has been assigned and will start to issue warnings. It also makes ReSharper very unhappy.
Can anyone suggest a better approach?
c # unit-testing dry nunit rhino-mocks
Generic Error
source share