Another more common (and easier to use if you are afraid of lambdas)
approach is to use a Mock and do an Expect() before the call itself occurs.
Then you can verify the expectation using VerifyAllExpectations() on the
Mock.  Look into Record/Replay syntax or AAA syntax.

On Wed, Dec 17, 2008 at 11:54 AM, Cvetomir Todorov <
[email protected]> wrote:

> You can use Rhino Mocks without lambda syntax. I think it's pain though.
> But if you want to - you should create a method that matches the
> Action<IViewMock> delegate signature and pass that to AssertWasCalled
> instead of the lambda.
>
> I suggest you read more about Rhino Mocks if you plan using it. There is an
> initial overhead which is overcomed after writing a few tests but you should
> first read a little. A good place to start from is
> http://ayende.com/wiki/Rhino+Mocks+Documentation.ashx.
>
> To read more about AssertWasCalled read
> http://ayende.com/wiki/Rhino+Mocks+3.5.ashx, and about the List constraint
> - http://ayende.com/wiki/Rhino+Mocks+Constraints.ashx.
>
> Good luck!
>
>
> On Wed, Dec 17, 2008 at 7:43 PM, [email protected] <
> [email protected]> wrote:
>
>>
>> Yes, this is exactly the case that I am interested in, however, I
>> could not figure out your response:
>>
>> viewMock.AssertWasCalled(view => view.ShowList(null), call =>
>> call.Constraints( /* you can use List constraint here to ensure args
>> are
>> correct */ ));
>>
>> What does AssertWasCalled do?  Is that lambda syntax that you are
>> using?  I'm not familiar with lambda syntax, and I fear that if
>> introduce lambda syntax to the team when I push for TDD, I may not
>> get
>> a lot of support.  Is there a way to accomplish the same functionality
>> without lambda syntax?
>>
>> On Dec 15, 1:56 pm, "Cvetomir Todorov"
>> <[email protected]> wrote:
>> > You can use DI to inject the view mock into the presenter. Then you need
>> to
>> > call the Present method of the presenter. The third step is to assert
>> that
>> > certain methods of the view have been called.
>> >
>> > // arrange
>> > IView viewMock = MockRepository.GenerateMock<IView>();
>> >
>> > // act
>> > var target = new Presenter(viewMock);
>> > target.Present( /* may be some data as an argument */ );
>> >
>> > // assert
>> > viewMock.AssertWasCalled(view => view.ShowList(null), call =>
>> > call.Constraints( /* you can use List constraint here to ensure args are
>> > correct */ ));
>> >
>> > On Mon, Dec 15, 2008 at 9:15 PM, [email protected] <
>> >
>> >
>> >
>> >
>> >
>> > [email protected]> wrote:
>> >
>> > > Actually, I would like to mock the view.
>> >
>> > > The presenter does some work and presents the view with:
>> > > 1. A List.
>> > >  -- I would like to be able to test that the list has the correct
>> > > number of items and that each item has the correct state
>> > > 2. A class
>> > >  -- I would like to verify that the class has the correct state
>> >
>> > > On Dec 12, 9:29 pm, "Shane Courtrille" <[email protected]>
>> > > wrote:
>> > > > Is this class something that your Presenter is generating?  Or is it
>> > > being
>> > > > provided to your presenter by another source (Repository.. Proxy)
>> which
>> > > > would have been provided to the presenter as a mock?
>> >
>> > > > If it's the 1st then you would want to capture the instance and
>> assert
>> > > > against it.  In this case you are only going to be using rhino mocks
>> to
>> > > get
>> > > > you the actual object.
>> >
>> > > > If its the 2nd then you have control over the source instance and
>> all you
>> > > do
>> > > > is once again capture the value that was passed to your view and
>> assert
>> > > that
>> > > > its the same instance you passed to the presenter in the first
>> place.  Of
>> > > > course if you make any changes and you can't do a simple assertion
>> you
>> > > will
>> > > > need to assert each property.
>> >
>> > > > On Fri, Dec 12, 2008 at 6:52 PM, [email protected] <
>> >
>> > > > [email protected]> wrote:
>> >
>> > > > > what happens when we mock the View (in MVP) and the presenter
>> sends a
>> > > > > class to the View?
>> >
>> > > > > using Rhino Mocks, how does one check that this class has the
>> right
>> > > > > data in it?  Is mocking even the correct tool to be using for
>> this?-
>> > > Hide quoted text -
>> >
>> > > > - Show quoted text -
>> >
>> > --
>> > Software modules coupling is the path to the dark side.
>> > Coupling leads to complexity.
>> > Complexity leads to confusion.
>> > Confusion leads to suffering.
>> > Once you start down the dark path, forever will it dominate your
>> destiny,
>> > consume you it will!- Hide quoted text -
>> >
>> > - Show quoted text -
>>
>>
>
>
> --
> Software modules coupling is the path to the dark side.
> Coupling leads to complexity.
> Complexity leads to confusion.
> Confusion leads to suffering.
> Once you start down the dark path, forever will it dominate your destiny,
> consume you it will!
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to