FindAll() public static method

public static FindAll ( ) : Castle.Facilities.ActiveRecordIntegration.Tests.Blog[]
return Castle.Facilities.ActiveRecordIntegration.Tests.Blog[]
Esempio 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);
        }
        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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
        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);
        }