public void NormalEntityShouldActuallyBeDeleted()
		{
			IDeleteEventListener[] defaultListeners = cfg.EventListeners.DeleteEventListeners;
            cfg.EventListeners.DeleteEventListeners = new IDeleteEventListener[] {new SoftDeleteEventListener()};
            using (ISession session = OpenSession())
            {
                int id;
                using (ITransaction transaction = session.BeginTransaction())
                {
                    RandomEntity ne = new RandomEntity();
                    ne.Name = "Bob";
                    session.Save(ne);
                    id = ne.Id;
                    transaction.Commit();
                }
                session.Clear();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    RandomEntity ne = session.Get<RandomEntity>(id);
                    session.Delete(ne);
                    transaction.Commit();
                }
                session.Clear();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    RandomEntity ne = session.Get<RandomEntity>(id);
                    Assert.IsNull(ne);
                    transaction.Commit();
                }
            }
			cfg.EventListeners.DeleteEventListeners = defaultListeners;
        }
Exemple #2
0
 public void NormalEntityShouldActuallyBeDeleted()
 {
     IDeleteEventListener[] defaultListeners = cfg.EventListeners.DeleteEventListeners;
     cfg.EventListeners.DeleteEventListeners = new IDeleteEventListener[] { new SoftDeleteEventListener() };
     using (ISession session = OpenSession())
     {
         int id;
         using (ITransaction transaction = session.BeginTransaction())
         {
             RandomEntity ne = new RandomEntity();
             ne.Name = "Bob";
             session.Save(ne);
             id = ne.Id;
             transaction.Commit();
         }
         session.Clear();
         using (ITransaction transaction = session.BeginTransaction())
         {
             RandomEntity ne = session.Get <RandomEntity>(id);
             session.Delete(ne);
             transaction.Commit();
         }
         session.Clear();
         using (ITransaction transaction = session.BeginTransaction())
         {
             RandomEntity ne = session.Get <RandomEntity>(id);
             Assert.IsNull(ne);
             transaction.Commit();
         }
     }
     cfg.EventListeners.DeleteEventListeners = defaultListeners;
 }