Sorry, for this mistake, but method is virtual!
Here is more info:

public class classA: baseClass
{

   public bool Success;

   protected virtual bool FileExists(string fileName)
   {
      return File.Exists(fileName);
   }

   protected virtual void Process(string fileName)
   {
     //Do something
     if(FileExists(fileName))
      {
       Success = true;
      }
     else
     {
      Success = false;
     }
  }
}

Unit test:

[TestMethod]
public void ProcessTest()
{
    var a = _mocks.StrickMock<baseClass>();
    Expect.Call(a.FileExists(null)).IgnoreArguments().Return(true);
    _mocks.ReplayAll();
   a.Process("test.test"); //File doesn't exists
   Assert.AreEqual(true, a.Success); //Fails here
}


On Mar 24, 1:39 pm, Alex McMahon <[email protected]> wrote:
> Method2 must be a virtual method for RhinoMocks to be able to mock the
> method with a PartialMock,
>
> On Tue, Mar 24, 2009 at 5:21 PM, Jake <[email protected]> wrote:
>
> > Ayende,
> > I am trying to use Rhino Mocks in following scenario:
>
> > void classA.Method1()
> > {
> >    //some stuff
> >    if(classA.Method2(var))
> >    {
> >        //Do something
> >  }
> >    else
> >  {
> >     //Do something else
> >  }
> >    //some other stuff
> > }
>
> > Now, I created partial mock for the class and set expectation for
> > Method2 like so:
>
> > Expect.Call(classAMock.Method2(null)).IgnoreArguments().Return(true);
>
> > Real implementation of the method returns false.
>
> > When I execute the test it goes through the path when Method2 returns
> > false.
>
> > How can that be?

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