Ejemplo n.º 1
0
        public void IsUniqueTimeoutExpiredBug()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog2), typeof(Blog5));
            Recreate();

            for (int i = 0; i < 5; i++)
            {
                Blog5 blog = new Blog5();
                blog.Name = "A cool blog";
                blog.Create();
            }

            Blog5 theBlog = new Blog5();

            theBlog.Name = "A cool blog";
            theBlog.Create();

            Blog5 anotherBlog = new Blog5();

            anotherBlog.Name = "A cool blog";
            anotherBlog.Create();

            anotherBlog.Name = "A very cool blog";
            anotherBlog.Update();

            Assert.IsFalse(Blog2.Find(theBlog.Id).IsValid());

            Blog2 weblog = new Blog2();

            weblog.Name = theBlog.Name;

            Assert.IsFalse(weblog.IsValid());

            weblog.Create();
        }
Ejemplo n.º 2
0
        public void IsUniqueWithSessionScope()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog2));
            Recreate();

            Blog2.DeleteAll();

            Blog2 blog = new Blog2();

            blog.Name = "hammett";
            blog.Create();

            using (new SessionScope())
            {
                Blog2 fromDb = Blog2.Find(blog.Id);
                fromDb.Name = "foo";
                fromDb.Save();
            }
        }
Ejemplo n.º 3
0
        public void ValidateIsUniqueWithinTransactionScope()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog2));
            Recreate();

            // The IsUniqueValidator was created a new SessionScope and causing an
            // error when used inside TransactionScope

            using (TransactionScope scope = new TransactionScope())
            {
                Blog2 blog = new Blog2();
                blog.Name = "A cool blog";
                blog.Create();

                blog      = new Blog2();
                blog.Name = "Another cool blog";
                blog.Create();

                scope.VoteCommit();
            }
        }
Ejemplo n.º 4
0
        public void IsUnique()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog2));
            Recreate();

            Blog2.DeleteAll();

            Blog2 blog = new Blog2();

            blog.Name = "hammett";
            blog.Create();

            blog      = new Blog2();
            blog.Name = "hammett";

            String[] messages = blog.ValidationErrorMessages;
            Assert.IsTrue(messages.Length == 1);
            Assert.AreEqual("Name is currently in use. Please pick up a new Name.", messages[0]);

            blog.Create();
        }