Thank you for your reply. In the second method, how would I go about
verifying that the method in question was called twice? With the more
robust syntax I could say:
LastCall.Repeat.Twice();
instead of just
LastCall.Repeat.Once();
I don't see a way to do that with the AssertWasCalled method.
On Mar 1, 3:18 pm, bill richards <[email protected]> wrote:
> The main difference is that the second version of your test is the
> preferred method ... the first uses Record/Replay syntax and can be
> somewhat confusing for some (most) users ... I really think that these
> members ought to be marked as deprecated in the next release.
>
> That's my two-cents' worth
>
> On Mar 1, 8:33 pm, Adam <[email protected]> wrote:
>
>
>
> > Sorry for such a basic post, but is there any real difference between
> > the two unit tests below? (the content is meaningless - just wanted
> > some interfaces to interact with each other). It seems like the
> > second one is much cleaner, but I'm not sure if I'm missing something.
>
> > Thanks!
>
> > [TestMethod]
> > public void Test1() {
> > var mocks = new MockRepository();
> > IStaleDataChecker sc =
> > mocks.StrictMock<IStaleDataChecker>();
> > IDAO dao = mocks.StrictMock<IDAO>();
> > IItem item = mocks.StrictMock<IItem>();
>
> > using (mocks.Record()) {
> > SetupResult.For(sc.IsGood(item)).Return(true);
>
> > dao.Save(item);
> > LastCall.Repeat.Once();
> > }
>
> > using (mocks.Playback()) {
> > Presenter P = new Presenter(sc, dao);
> > P.Run(item);
> > }
> > }
>
> > [TestMethod]
> > public void Test2() {
> > IStaleDataChecker sc =
> > MockRepository.GenerateMock<IStaleDataChecker>();
> > IDAO dao = MockRepository.GenerateMock<IDAO>();
> > IItem item = MockRepository.GenerateMock<IItem>();
>
> > sc.Expect(S => S.IsGood(item)).Return(true);
>
> > Presenter P = new Presenter(sc, dao);
> > P.Run(item);
>
> > dao.AssertWasCalled(d => d.Save(item));
> > }- Hide quoted text -
>
> - Show quoted text -
--
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.