public void CollectionIntercept() { ISession s = OpenSession(new CollectionInterceptor()); ITransaction t = s.BeginTransaction(); User u = new User("Gavin", "nivag"); s.Persist(u); u.Password = "******"; t.Commit(); s.Close(); s = OpenSession(); t = s.BeginTransaction(); u = s.Get<User>("Gavin"); Assert.AreEqual(2, u.Actions.Count); s.Delete(u); t.Commit(); s.Close(); }
public void PropertyIntercept() { ISession s = OpenSession(new PropertyInterceptor()); ITransaction t = s.BeginTransaction(); User u = new User("Gavin", "nivag"); s.Persist(u); u.Password = "******"; t.Commit(); s.Close(); s = OpenSession(); t = s.BeginTransaction(); u = s.Get<User>("Gavin"); Assert.IsTrue(u.Created.HasValue); Assert.IsTrue(u.LastUpdated.HasValue); s.Delete(u); t.Commit(); s.Close(); }
/* * Here the interceptor resets the * current-state to the same thing as the current db state; this * causes EntityPersister.FindDirty() to return no dirty properties. */ public void PropertyIntercept2() { ISession s = OpenSession(); ITransaction t = s.BeginTransaction(); User u = new User("Josh", "test"); s.Persist(u); t.Commit(); s.Close(); s = OpenSession(new HHH1921Interceptor()); t = s.BeginTransaction(); u = s.Get<User>(u.Name); u.Password = "******"; t.Commit(); s.Close(); s = OpenSession(); t = s.BeginTransaction(); u = s.Get<User>("Josh"); Assert.AreEqual("test", u.Password); s.Delete(u); t.Commit(); s.Close(); }
public void StatefulIntercept() { StatefulInterceptor statefulInterceptor = new StatefulInterceptor(); ISession s = OpenSession(statefulInterceptor); Assert.IsNotNull(statefulInterceptor.Session); ITransaction t = s.BeginTransaction(); User u = new User("Gavin", "nivag"); s.Persist(u); u.Password = "******"; t.Commit(); s.Close(); s = OpenSession(); t = s.BeginTransaction(); IList logs = s.CreateCriteria(typeof(Log)).List(); Assert.AreEqual(2, logs.Count); s.Delete(u); s.Delete("from Log"); t.Commit(); s.Close(); }