Really? I find this scenario extremely normal when doing non Context/ Specification testing...
[TestFixture] public class FooServiceLayerTest [Test] public void PostFooToSAP_ShouldRetrieveFooFromRepository - has an expectation of repository being called. [Test] public void PostFooToSAP_ShouldCreateSAPMessageBasedOffFoo - needs a stub on repository to return foo [Test] public void PostFooToSAP_ShouldSendFooMessageToSAP - needs a stub on repository to return foo // More tests that all require a stub on repository to return foo So now rather then having the stub on each test I like to pull it up into the test [SetUp]... On Jun 11, 1:30 pm, Tim Barcz <[email protected]> wrote: > What is the usage scenario for this...seems odd to have an expectation and a > stub all at the same time. > > Tim > > > > On Thu, Jun 11, 2009 at 12:05 PM, Shane C <[email protected]> wrote: > > > I seem to be going crazy because I swear that the following was > > legal... > > > [SetUp] > > public void BeforeEachTest() > > { > > m_EngineMock = MockRepository.GenerateMock<Engine>(); > > > m_EngineMock.Stub(stub => stub.Execute(null, null) > > .IgnoreArguments() > > .Return(new Result()); > > } > > > // Tests that need the stub to exist... > > > [Test] > > public void TestThatVerfiesTheEngineIsBeingExecuted() > > { > > m_EngineMock.Expect(mock = mock.Execute(var1, var2) > > .Repeat.AtLeastOnce() > > .Return(new Result()); > > > m_SUT.Execute(); > > > m_EngineMock.VerifyAllExpectations(); > > } > > > When I try to do something similar to this my expectation never > > passes. The stub is blocking it but I could have sworn I'd done this > > before... > > -- > Tim Barcz > ASPInsiderhttp://timbarcz.devlicio.ushttp://www.twitter.com/timbarcz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
