public void Fail_if_an_entity_was_not_found() { Guid entityID = Guid.NewGuid(); using (Record) { _mockSession.FlushMode = FlushMode.Commit; Expect.Call(_mockSession.IsOpen).Return(true); Expect.Call(_mockSession.Load<FakeEntity>(entityID)).Throw( new UnresolvableObjectException(entityID, typeof(FakeEntity))); } using (Playback) { NHibernateSessionAdapter sessionAdapter = new NHibernateSessionAdapter(_mockSession); try { sessionAdapter.Load<FakeEntity>(entityID); } catch (EntityNotFoundException ex) { Assert.AreEqual(entityID, ex.SuppliedEntityID); throw; } } }
public void Delegate_to_an_NHibernate_session() { FakeEntity fakeEntity = new FakeEntity(); using (Record) { _mockSession.FlushMode = FlushMode.Commit; Expect.Call(_mockSession.IsOpen).Return(true); Expect.Call(_mockSession.Load<FakeEntity>(Guid.NewGuid())).Return(fakeEntity); LastCall.IgnoreArguments(); } using (Record) { NHibernateSessionAdapter sessionAdapter = new NHibernateSessionAdapter(_mockSession); sessionAdapter.Load<FakeEntity>(new Guid()); } }