The main thing is a concpetual difference.I would use stub if I don't care
about what is going to happen
I would use a mock if I do care.
On Fri, Nov 7, 2008 at 2:05 PM, Tim Barcz <[EMAIL PROTECTED]> wrote:
> I am working on a presentation and was about to make the assertion, "stubs
> can't have expectations set on them". I decide to double check myself and
> run the following code and see that I can set expectations. (Removing the
> call to logger.Log in the Order method causes the test to fail).
>
> [TestFixture]
> public class Stubs
> {
> [Test]
> public void CreateStub()
> {
> var logger = MockRepository.GenerateStub<ILogger>();
>
> var svc = new OrderService(logger);
>
> svc.Order();
>
> logger.AssertWasCalled(x=>x.Log("hello"));
> }
>
> public class OrderService
> {
> private readonly ILogger logger;
>
> public OrderService(ILogger logger)
> {
> this.logger = logger;
> }
>
> public void Order()
> {
> logger.Log("hello");
> }
> }
> }
>
> public interface ILogger
> {
> void Log(string message);
> }
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---