|
Adding in all the features I wished NMock had build in. Mocking EventsStub.On(mock_with_events).EventAdd("eventname", Is.Anything).Will(Remember.EventAdd);
Stub.On(mock_with_events).EventRemove("eventname", Is.Anything).Will(Remember.EventRemove);
// perform action that makes someone listen to the event.
...
//simulate firing event
Event.Fire("eventname", mock_with_events, new EventArgs());
Mocking Generic MethodsStub.On(childScope)
.Method(new GenericMethodMatcher("MethodName", typeof(Type1), typeof(Type2))
.Will(Return.Value(NewMock<Type2>()));
Stub.On(childScope)
.Method(new GenericMethodMatcher("MethodName", typeof(Type1), typeof(Type3))
.Will(Return.Value(NewMock<Type3>()));.Net 3.5 people can now do this... Stub.On(childScope)
.Method<Type1, Type3>("MethodName")
.Will(Return.Value(NewMock<Type3>()));Simple! DRY FixturesDerive your test fixtures from MockingTestFixture. You don't need:- mocks = new Mockery();
//or
mocks.VerifyAllExpectationsHaveBeenMet(); And... // Before:
mockCurrencyService = mocks.NewMock<ICurrencyService>();
//After:
mockCurrencyService = NewMock<ICurrencyService>();Note: protected override void SetUp()
{
...
}replaces... [SetUp]
public void SetUp()
{
...
}
|