I've done testing for *several *years and I've rarely come across a scenario
where I've needed to test getters/setters (when I've done that i've largely
probably done something wrong).

Here is the advice I'd give, only test interaction on void method calls,
otherwise test state.  This isn't really AAA advice but advice in general.

On Fri, Dec 31, 2010 at 11:28 PM, Chris May <[email protected]>wrote:

> > "but I believe I should be able to assert that a property get and
> property
> > set methods were called right?"
> >
> > Can you explain why you would need to do this?  In order to assert that
> > something was set you're correct, just check the value.
>
> Aren't these things that could come up if you are testing the
> interaction?  The tests I'm writing for my project at the moment don't
> require this level of information, but I would think you might want to
> verify something like "Property X was set only 1 time, not multiple
> times" or "Property X was set to N and then set to J".
>
> Regarding the property get, I would think it might be along the same
> lines as why you'd want to know that a function was called on the
> mocked object.  If you are testing the interaction I don't think it
> would be all that rare to say:
> mock.AssertWasCalled(x => x.GetName());
> which would basically be the same as if you choose to use readonly
> property instead of a function:
> mock.AssertWasCalled(x => x.Name());
>
> This is really more of me just trying to understand the AAA method of
> setting up tests.
>
> From all the things I've tried, I think it looks like you can't verify
> properties were read or set if they are setup with PropertyBehavior.
> If I use a mock and I don't turn on property behavior then it looks
> like things start working.
>
> Not a big deal, I'll probably never need to know it, but I was just
> trying to grok this subject a bit.
>
> --
> 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]<rhinomocks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rhinomocks?hl=en.
>
>


-- 
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

-- 
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