public void NonTransactionalRootStateless()
        {
            ISessionManager sessionManager = container.Resolve <ISessionManager>();

            ITransaction transaction;

            using (IStatelessSession session = sessionManager.OpenStatelessSession())
            {
                transaction = session.Transaction;

                Assert.IsFalse(transaction.IsActive);

                FirstDao  first  = container.Resolve <FirstDao>("myfirstdao");
                SecondDao second = container.Resolve <SecondDao>("myseconddao");

                // This call is transactional
                Blog blog = first.CreateStateless();

                // TODO: Assert transaction was committed
                // Assert.IsTrue(session.Transaction.WasCommitted);

                try
                {
                    second.CreateWithExceptionStateless2(blog);
                }
                catch (Exception)
                {
                    // Expected
                }

                // TODO: Assert transaction was rolledback
                // Assert.IsTrue(session.Transaction.WasRolledBack);

                RootService rootService = container.Resolve <RootService>();

                Array blogs = rootService.FindAllStateless(typeof(Blog));
                Assert.AreEqual(1, blogs.Length);
                Array blogitems = rootService.FindAllStateless(typeof(BlogItem));
                Assert.IsEmpty(blogitems);
            }
        }
        public void NonTransactionalRoot()
        {
            ISessionManager sessionManager = (ISessionManager)
                                             container[typeof(ISessionManager)];

            using (ISession session = sessionManager.OpenSession())
            {
                Assert.IsNull(session.Transaction);

                FirstDao  first  = (FirstDao)container["myfirstdao"];
                SecondDao second = (SecondDao)container["myseconddao"];

                // This call is transactional
                Blog blog = first.Create();

                Assert.IsTrue(session.Transaction.WasCommitted);

                try
                {
                    second.CreateWithException2(blog);
                }
                catch (Exception)
                {
                    // Expected
                }

                Assert.IsTrue(session.Transaction.WasRolledBack);

                RootService rootService = (RootService)container["root"];

                Array blogs = rootService.FindAll(typeof(Blog));
                Assert.AreEqual(1, blogs.Length);
                Array blogitems = rootService.FindAll(typeof(BlogItem));
                Assert.IsNull(blogitems);
            }
        }
		public RootService(FirstDao firstDao, SecondDao secondDao, ISessionManager sessManager) : base(sessManager)
		{
			this.firstDao = firstDao;
			this.secondDao = secondDao;
		}
Exemplo n.º 4
0
 public RootService(FirstDao firstDao, SecondDao secondDao, ISessionManager sessManager) : base(sessManager)
 {
     this.firstDao  = firstDao;
     this.secondDao = secondDao;
 }