Google Groups Home
Help | Sign in
Message from discussion CallOriginalMethod
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Ayende Rahien  
View profile
 More options Mar 14 2007, 5:08 pm
From: "Ayende Rahien" <aye...@ayende.com>
Date: Wed, 14 Mar 2007 23:08:49 +0200
Local: Wed, Mar 14 2007 5:08 pm
Subject: Re: CallOriginalMethod

Fixed, thanks.

On 3/12/07, Ayende Rahien <aye...@ayende.com> wrote:

> That is because NoExpectations are handled in the interceptor level, not
> in the mock state layer, thanks for finding it out.

> On 3/12/07, ernst80 < ernst.scheitha...@gmx.net> wrote:

> > Hi Ayende,

> > Thanks for fixing this. This is definitely helpful to us.

> > When I tested the new implementation of CallOriginalMethod I went
> > across the following:

> >     public class TestClass
> >     {
> >       public virtual void Method () { }
> >     }

> >     [Test]
> >     public void TestName ()
> >     {
> >       MockRepository repository = new MockRepository ();
> >       TestClass mock = repository.CreateMock<TestClass> ();

> >       mock.Method ();
> >       LastCall.CallOriginalMethod
> > (Rhino.Mocks.Interfaces.OriginalCallOptions.NoExpectation );

> >       repository.ReplayAll ();
> >       mock.Method ();
> >       repository.VerifyAll ();

> >       repository.BackToRecordAll ();

> >       mock.Method ();
> >       LastCall.Throw (new ApplicationException ());

> >       repository.ReplayAll ();

> >       try
> >       {
> >         mock.Method ();
> >         Assert.Fail ();
> >       }
> >       catch (ApplicationException ex)
> >       {
> >       }
> >     }

> > The test is green when I use OriginalCallOptions.CreateExpectation.

> > This test fails. I give it to you just as a feedback since I currently
> > do not need a different behavior. It it seems easy to work around it
> > with LastCall.IgnoreArguments ().CallOriginalMethod
> > (OriginalCallOptions.CreateExpectations) instead of using
> > using .NoException.

> > However it is not obvious to me why the mock has this behavior after
> > BackToRecord ();

> > Best regrads,
> > Ernst

> > On Mar 6, 3:42 am, "Ayende Rahien" <aye...@ayende.com> wrote:
> > > I am an idiot.
> > > I am invoking the previous invocation!
> > > Fixed, thanks for spotting this.

> > > On 2/26/07, ernst80 <ernst.scheitha...@gmx.net> wrote:

> > > > Hi Ayende,

> > > > wow, that was fast!

> > > > Unfortunately, the implementation does not behave as expected. The
> > > > following example simplifies the scenario:

> > > >     public class MockedClass
> > > >     {
> > > >       public virtual void Method (string parameter)
> > > >       {
> > > >         if (parameter == null)
> > > >           throw new ArgumentNullException ();

> > > >         //Something in this method must be executed
> > > >       }
> > > >     }

> > > >     [Test]
> > > >     public void CallOriginalMethodProblem2 ()
> > > >     {
> > > >       MockRepository mockRepository = new MockRepository ();
> > > >       MockedClass mock = mockRepository.CreateMock<MockedClass> ();

> > > >       mock.Method (null);
> > > >       LastCall.Constraints (Is.Equal("parameter")).CallOriginalMethod
> > > > (OriginalCallOptions.CreateExpectation );

> > > >       mockRepository.ReplayAll ();

> > > >       mock.Method ("parameter");

> > > >       mockRepository.VerifyAll ();
> > > >     }

> > > > The ArgumentNullException is thrown in this case, although
> > "parameter"
> > > > should be passed, as it was before the parameter was added to
> > > > CallOriginalMethod.

> > > > Could you please look into it?

> > > > Thanks, Ernst

> > > > On Feb 24, 1:55 pm, "Ayende Rahien" < aye...@ayende.com> wrote:
> > > > > I have obsoloted CallOriginalMethod, instead we have:

> > > > > CallOriginalMethod(OriginalCallOptions.CreateExpectation )
> > > > > CallOriginalMethod(OriginalCallOptions.NoExpectation)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google