Loading...

RhinoMocks@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

[RhinoMocks] how do i mock UnitOfWork.Current.BeginTransaction()? beto Tue Oct 19 15:00:06 2010

Hi Everyone,
I’m using rhino.commons and would like to test the following piece of
code below but I’m having trouble Mokin
UnitOfWork.Current.BeginTransaction().  I was able to mock the unit of
work doing the following:
var theStubUnitOfWork = MockRepository.GenerateMock<IUnitOfWork>();
            UnitOfWork.RegisterGlobalUnitOfWork(theStubUnitOfWork);

But I want to be able to do something similar with RhinoTransaction, I
have tried this: var tx =
MockRepository.GenerateMock<RhinoTransaction>();

But how do I register it as a global.  Any help would be appreciated
and thanks in advanced.
if (isAllowedToRemove && hasAccessOnOrg)
            {
                RhinoTransaction tx =
UnitOfWork.Current.BeginTransaction();
                try
                {
                    //do stuff
                    tx.Commit();
                }
                catch
                {
                    tx.Rollback();
                }
                finally
                {
                    tx.Dispose();
                }
            }

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