コード例 #1
0
        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;
            }
             }
        }
コード例 #2
0
        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());
             }
        }