DeleteAll() public static method

public static DeleteAll ( ) : void
return void
Ejemplo n.º 1
0
        public void TransactionUsingParentSessionScope2()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            using (new SessionScope())
            {
                Blog.FindAll();                 // side effects only

                BlogService service = container.Resolve <BlogService>();
                Blog        blog    = service.Create("name", "author");

                try
                {
                    service.ModifyAndThrowException2(blog, "name2");
                    Assert.Fail("Exception expected");
                }
                catch (Exception) {}
            }

            Assert.AreEqual(1, Blog.FindAll().Length);
            Blog blog2 = Blog.FindAll()[0];

            Assert.AreEqual("name", blog2.Name);
        }
Ejemplo n.º 2
0
        public void SimpleUsage()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            Blog[] blogs = Blog.FindAll();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(0, blogs.Length);

            Blog blog = new Blog();

            blog.Name   = "hammett's blog";
            blog.Author = "hamilton verissimo";
            blog.Save();

            blogs = Blog.FindAll();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Length);

            Blog retrieved = blogs[0];

            Assert.IsNotNull(retrieved);

            Assert.AreEqual(blog.Name, retrieved.Name);
            Assert.AreEqual(blog.Author, retrieved.Author);
        }
Ejemplo n.º 3
0
        public void OneLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            BlogService service = container.Resolve <BlogService>();

            service.Create("name", "author");

            Assert.AreEqual(1, Blog.FindAll().Length);
        }
Ejemplo n.º 4
0
        public void OneLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            BlogService service = (BlogService)container[typeof(BlogService)];

            service.Create("name", "author");

            Assert.AreEqual(1, Blog.FindAll().Length);
        }
Ejemplo n.º 5
0
        public void TwoLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            FirstService service = container.Resolve <FirstService>();

            service.CreateBlogAndPost();

            Assert.AreEqual(1, Blog.FindAll().Length);
            Assert.AreEqual(1, Post.FindAll().Length);
        }
Ejemplo n.º 6
0
        public void TwoLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            FirstService service = (FirstService)container[typeof(FirstService)];

            service.CreateBlogAndPost();

            Assert.AreEqual(1, Blog.FindAll().Length);
            Assert.AreEqual(1, Post.FindAll().Length);
        }
Ejemplo n.º 7
0
        public void OneLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            using (new SessionScope())
            {
                Blog.FindAll();                 // side effects only

                BlogService service = container.Resolve <BlogService>();
                service.Create("name", "author");
            }

            Assert.AreEqual(1, Blog.FindAll().Length);
        }
Ejemplo n.º 8
0
        public void OneLevelTransactionRollback1()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            BlogService service = container.Resolve <BlogService>();

            try
            {
                service.CreateAndThrowException("name", "author");
            }
            catch (Exception)
            {
            }

            Assert.AreEqual(0, Blog.FindAll().Length);
        }
Ejemplo n.º 9
0
        public void TwoLevelTransaction()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            FirstService service = container.Resolve <FirstService>();

            using (new SessionScope())
            {
                Blog.FindAll();                 // side effects only

                service.CreateBlogAndPost();
            }

            Assert.AreEqual(1, Blog.FindAll().Length);
            Assert.AreEqual(1, Post.FindAll().Length);
        }
Ejemplo n.º 10
0
        public void OneLevelTransactionRollback2()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            BlogService service = (BlogService)container[typeof(BlogService)];

            try
            {
                service.CreateAndThrowException2("name", "author");
            }
            catch (Exception)
            {
            }

            Assert.AreEqual(0, Blog.FindAll().Length);
        }
Ejemplo n.º 11
0
        public void TwoLevelTransaction2()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            FirstService service = container.Resolve <FirstService>();

            try
            {
                service.CreateBlogAndPost2();
            }
            catch (Exception)
            {
            }

            Assert.AreEqual(0, Blog.FindAll().Length);
            Assert.AreEqual(0, Post.FindAll().Length);
        }
Ejemplo n.º 12
0
        public void DicardingChanges()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            SessionScope scope = new SessionScope(FlushAction.Never);

            Blog.FindAll();             // side effects only

            BlogService service = container.Resolve <BlogService>();
            Blog        blog    = service.Create("name", "author");

            Assert.AreEqual(1, Blog.FindAll().Length);

            blog.Name = "joe developer";

            scope.Dispose();

            Assert.AreEqual("name", Blog.FindAll()[0].Name);
        }
Ejemplo n.º 13
0
        public void DicardingChanges()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            SessionScope scope = new SessionScope();

            Blog.FindAll();             // side effects only

            BlogService service = (BlogService)container[typeof(BlogService)];
            Blog        blog    = service.Create("name", "author");

            Assert.AreEqual(1, Blog.FindAll().Length);

            blog.Name = "joe developer";

            scope.Dispose(true);

            Assert.AreEqual("name", Blog.FindAll()[0].Name);
        }
Ejemplo n.º 14
0
        public void OneLevelTransactionRollback1()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            BlogService service = container.Resolve <BlogService>();

            using (new SessionScope())
            {
                Blog.FindAll();                 // side effects only

                try
                {
                    service.CreateAndThrowException("name", "author");
                }
                catch (Exception)
                {
                }
            }

            Assert.AreEqual(0, Blog.FindAll().Length);
        }
Ejemplo n.º 15
0
        public void TwoLevelTransaction2()
        {
            Post.DeleteAll();
            Blog.DeleteAll();

            FirstService service = (FirstService)container[typeof(FirstService)];

            using (new SessionScope())
            {
                Blog.FindAll();                 // side effects only

                try
                {
                    service.CreateBlogAndPost2();
                }
                catch (Exception)
                {
                }
            }

            Assert.AreEqual(0, Blog.FindAll().Length);
            Assert.AreEqual(0, Post.FindAll().Length);
        }