public void SetUpContext() { ResetUnitOfWork(); _factory = _mocks.DynamicMock<IUnitOfWorkFactory>(); _unitOfWork = _mocks.DynamicMock<IUnitOfWork>(); _session = _mocks.DynamicMock<ISession>(); //var fieldInfo = typeof(UnitOfWork).GetField("_innerUnitOfWork", // BindingFlags.Static | BindingFlags.SetField | BindingFlags.NonPublic); //fieldInfo.SetValue(null, null); InstrumentUnitOfWork(); _mocks.BackToRecordAll(); SetupResult.For(_factory.Create(dbKey)).Return(_unitOfWork); SetupResult.For(_factory.GetCurrentSession(dbKey)).Return(_session); SetupResult.For(_unitOfWork.DatabaseKey).Return(dbKey); _mocks.ReplayAll(); }