private CreateWithException2 ( Blog blog ) : BlogItem | ||
blog | Blog | |
리턴 | BlogItem |
public void NonTransactionalRoot() { ISessionManager sessionManager = container.Resolve <ISessionManager>(); ITransaction transaction; using (ISession session = sessionManager.OpenSession()) { 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.Create(); // TODO: Assert transaction was committed // Assert.IsTrue(session.Transaction.WasCommitted); try { second.CreateWithException2(blog); } catch (Exception) { // Expected } // TODO: Assert transaction was rolledback // Assert.IsTrue(session.Transaction.WasRolledBack); RootService rootService = container.Resolve <RootService>(); Array blogs = rootService.FindAll(typeof(Blog)); Assert.AreEqual(1, blogs.Length); Array blogitems = rootService.FindAll(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 virtual void CallWithException2() { Blog blog = firstDao.Create(); secondDao.CreateWithException2(blog); }