Hi Adam:

Basically, kind of. Its really the conditions that cause _hasSession
to be true or false that I'm testing, with the call to
session.BeginTransaction() being all I need to verify. So I have
transaction as a stub and session as a mock.

Maybe I'm not totally understanding this the way Expect should be used
with a mock. I'm thinking that if the session is the mocked object,
then

    session.Expect(x => x.BeginTransaction())   // .Return(tx);

creates an expectation of a call to be verified (ie, later, as in
session.VerifyAllExpectations), just as AssertWasCalled
(x=>x.BeginTransaction) does in one line. I'm further thinking that
the .Return(tx) is a convenience to return the stubbed value, and if
that works on Expect, why shouldn't it work as a method option also.

Does that make sense?

Thx,
Berryl

> public void TestNoExistingSessionBeginsNewTransaction()
> {
>   // Arrange
>   var session = MockRepository.GenerateMock<ISession>();
>   var tx = MockRepository.GenerateMock<ITransaction>();
>   var sut = new Sut(session);
>   sut.HasExistingSession = false;
>   session.Expect(x => x.BeginTransaction()).Return(tx);
>
>   // Act
>   sut.TransactionSave("foo");
>
>   // Assert
>   session.AssertWasCalled(x => x.Save("foo");
>   session.AssertWasCalled(x => x.BeginTransaction());
>   tx.AssertWasCalled(x => x.Commit());
>
> }

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