Thanks for your replyes..

The senario I have is

public class fooClass {

public void methodToTest {

   ....
   calls foo1
   calls foo2
}

}


I want to test if the "methodToTest" calls foo2 but I don't want it to
break when calling foo1 and I want to use Partial Mocks because I want
the test to use the actual methods when not set in the expectations

[testMethod()]
public void test()
{
    MockRepository mocks = new MockRepository();

    fooClass fakeClass = mocks.PartialMock<fooClass>();

  **  fakeClass.Stub(x => x.foo1()).whenCalled(x => ;);

    using(mocks.Record())
   {
        fakeClass.foo2();
   }

   mocks.Verify(fakeClass);

}

How do I Stub foo1 on line *, I don't want to assert anything against
it I just don't want to break my test becuase it is talking to an
outsource dependency?

Thanks,

Samah


On Aug 17, 9:11 pm, Tim Barcz <[email protected]> wrote:
> Per my original email, I would actually suggest using a mock
> MockRepository.GenerateMock<IFoo>();
>
> While you *can* assert on Stubs, it's muddied the waters a bit and the more
> semantically correct use is a Mock.
>
> Tim
>
>
>
>
>
> On Tue, Aug 17, 2010 at 8:16 PM, David Tchepak <[email protected]> wrote:
> > public interface IFoo {
> >   void DoFoo();
> > }
>
> > var foo = MockRepository.GenerateStub<IFoo>();
>
> > //Do something when void method is called:
> > foo.Stub(x => x.DoFoo()).WhenCalled(x => RunSomeCode());
>
> > //Assert void method was called
> > foo.AssertWasCalled(x => x.DoFoo());
>
> > Hope this helps.
> > Regards,
> > David
>
> > On Wed, Aug 18, 2010 at 5:36 AM, samah <[email protected]> wrote:
>
> >> Hi all,
>
> >> How can we stub a method that returns nothing using Rhino Mocks?
>
> >> Thanks,
>
> >> -Samah
>
> >> --
> >> 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%2bunsubscr...@googlegrou­ps.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/rhinomocks?hl=en.
>
> >  --
> > 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%2bunsubscr...@googlegrou­ps.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rhinomocks?hl=en.
>
> --
> Tim Barcz
> Microsoft C# MVP
> Microsoft 
> ASPInsiderhttp://timbarcz.devlicio.ushttp://www.twitter.com/timbarcz- 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.

Reply via email to