Hello:

Here is a code snippet that I can test successfully without complete
AAA:

private void TransactionalSave(object propertyValue)
        {
            if (_hasExistingSession)
                _currentSession.Save(propertyValue);
            else
                using (var tx = _currentSession.BeginTransaction())
                {
                    _currentSession.Save(propertyValue);
                    tx.Commit();
                }
        }

If I tell the mocked ISession to:
            _session.Expect(x => x.BeginTransaction()).Return
(MockRepository.GenerateStub<ITransaction>());
           ....
           _session.VerifyAllExpectations();

then the using statement (tx) variable is successfully stubbed out to
make for a useful test.

I'd much prefer to use AssertWasCalled(x=>x.BeginTrans.., mo=>mo.Return
(stub)) but this leaves the tx variable unstubbed, ruining the test
with a NullRefException on tx.Commit(). Is there some way I can eat my
AAA cake, or is this a situation where I just can't?

Cheers,
Berryl
--~--~---------~--~----~------------~-------~--~----~
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