|
From: Steve M. <Ste...@ty...> - 2007-10-12 20:50:16
|
There is currently not a unit test for the FireAction class, which is
meant to fire an event in response to an expectation. I'm trying to
write some documentation for the event class and think that for clarity
we should try and combine the two actions. I'm not sure how to proceed
at the moment though. I see a couple of possible paths.
1.=20
Leave the Fire class alone.
Create a parallel 'Cause' class that holds the actions for Event,
SetNamedParameter, and SetIndexedParameter (which currently must be
created by hand).
There will need to be a different interface for the final stop on the
cause class for events because it doesn't require an object and must
return an action. Currently the Fire class fires the event.
2.=20
Break the Fire class but set it up to combine with the Cause class. The
new syntax would look like
Fire.Event("Foo").On(mockInterfaceWithEvents).With(mockInterfaceWithEven
ts,EventArgs.Empty).Now();
And
Expect.Once.On(mockInterfaceWithEvents).Method("CausesEventToFire").With
NoArguments().
=20
Will(Cause.Event("Foo").With(mockInterfaceWithEvents,EventArgs.Empty).To
Fire());
I hesitate to break existing code (especially mine), but I think now is
the time to make adjustments before an official release that includes
the event stuff.
To complete the discussion the Cause will also have
Expect.Once.On(mock).Method("MethodWithRefParameters").With(Is.Out).Will
(Cause.NamedParameter("foo").ToBe("bar"));
Expect.Once.On(mock).Method("MethodWithRefParameters").With(Is.Out).Will
(Cause.IndexedParameter(0).ToBe("bar""));
Any comments on a course of action would be appreciated, I prefer 2
unless anyone has a better suggestion.
|