Exemple #1
0
        public void FlowTest()
        {
            var manager = new MiniSessionManager();

            var session = manager.OpenSession();

            var sessionNew = manager.OpenSession();

            Assert.AreSame(session, sessionNew);

            manager.LastAction = RepositoryAction.INSERT;
            Assert.AreEqual(RepositoryAction.INSERT, manager.LastAction);
            manager.BeginTransaction();
            manager.WillFlush = true;
            manager.CommitChanges();
        }
        public void GetOriginalEntityPropertyTest()
        {
            var manager = new MiniSessionManager();
            var session = manager.OpenSession();

            Assert.AreEqual(null, session.GetOriginalEntityProperty(new User(), "Name"));
        }
        public void IsDirtyPropertyTest()
        {
            var manager = new MiniSessionManager();
            var session = manager.OpenSession();

            Assert.IsFalse(session.IsDirtyProperty(new User(), "Name"));
        }
        public void IsDirtyEntityTest()
        {
            var manager = new MiniSessionManager();
            var session = manager.OpenSession();

            Assert.IsTrue(session.IsDirtyEntity(new User()));
        }
        public void PrintSessionStatisticsTest()
        {
            var manager = new MiniSessionManager();

            var session = manager.OpenSession();

            session.PrintSessionStatistics();
        }
Exemple #6
0
        public void IsPersistedTest()
        {
            var obj = new ObjectGraphWalker();

            var manager = new MiniSessionManager();
            var session = manager.OpenSession();

            Assert.AreEqual(null, obj.IsPersisted(new User(), session));
        }
Exemple #7
0
 public Repository(MiniSessionManager manager = null)
 {
     _sessionManager = manager;
     if (_sessionManager == null)
     {
         _sessionManager = MiniSessionManager.Instance;
     }
     // Make sure the session is open
     _sessionManager.OpenSession();
     _currentSession = _sessionManager.Session;
 }
Exemple #8
0
        public void FlowExceptionTest()
        {
            var manager = new MiniSessionManager
            {
                Session = null
            };

            Assert.ThrowsException <ApplicationException>(() => { manager.CommitChanges(); });
            manager.CommitChanges(new Exception());

            var session = manager.OpenSession();

            var sessionNew = manager.OpenSession();

            Assert.AreSame(session, sessionNew);

            manager.BeginTransaction();

            manager.CommitChanges(new Exception());
        }
Exemple #9
0
        public void AssociateGraphWithSessionTest()
        {
            var obj = new ObjectGraphWalker();

            var manager = new MiniSessionManager();
            var session = manager.OpenSession();

            Assert.AreEqual(null, obj.IsPersisted(new User(), session));
            var user = obj.AssociateGraphWithSession(new User(), manager);
            //Assert.AreEqual("", user.Name);
        }
Exemple #10
0
 private ISession GetCurrentSession()
 {
     // Make sure session is open
     _sessionManager.OpenSession();
     return(_sessionManager.Session);
 }