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(); }
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(); } }
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(); } }
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(); }
public void IsUniqueWithInvalidData() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog2), typeof(Blog2B)); Recreate(); Blog2B.DeleteAll(); Blog2B blog = new Blog2B(); blog.Name = "hammett"; blog.Create(); blog = new Blog2B(); blog.Name = "hammett"; blog.Create(); Blog2 blog2 = new Blog2(); blog2.Name = blog.Name; Assert.IsFalse(blog2.IsValid()); }
public void IsUniqueDoesNotDeadlockOnAutoflushTransaction() { InPlaceConfigurationSource source = (InPlaceConfigurationSource)GetConfigSource(); DefaultFlushType originalType = source.DefaultFlushType; try { ActiveRecordStarter.Initialize(source, typeof(Blog2)); Recreate(); source.DefaultFlushType = DefaultFlushType.Auto; using (new TransactionScope()) { Blog2.DeleteAll(); Blog2 blog = new Blog2(); blog.Name = "FooBar"; blog.Save(); } } finally { source.DefaultFlushType = originalType; } }
///// <summary> ///// Test Sample Storage ///// </summary> //public static void Ts(bool Ensure = true) //{ // if (Ensure) // new BloggingContext().N(); // AppDataModels.sv(); //} /// <summary> /// Test Sample Storage with custom context /// </summary> public static void Tcs(bool Ensure = true) { var cs = new DCx <Blog2, Post2>(); if (Ensure) { cs.N(); } cs.U(c => { var b = new Blog2() { Url = "fghfgh " }; b.Posts = new List <Post2>(); b.Posts.Add(new Post2() { Content = "gdf dgdg ", Title = "gfhjfghg hhfh" }); b.Posts.Add(new Post2() { Content = "gdf dgdg 3232423", Title = "gfhjfghg hhfh 2422342423" }); c.d1.Add(b); }); var cs2 = new DCx <Blog2, Post2>(); cs2.R(c => { var tt = c.d1.Include(blog => blog.Posts).L(); }); //AppDataModels.sv(); }
public void IsUniqueDoesNotDeadlockOnAutoflushTransaction() { InPlaceConfigurationSource source = (InPlaceConfigurationSource)GetConfigSource(); DefaultFlushType originalType = source.DefaultFlushType; try { ActiveRecordStarter.Initialize(source, typeof(Blog2)); Recreate(); source.DefaultFlushType = DefaultFlushType.Auto; using (new TransactionScope()) { Blog2.DeleteAll(); Blog2 blog = new Blog2(); blog.Name = "FooBar"; blog.Save(); } } finally { source.DefaultFlushType = originalType; } }
public void IsUnique() { ActiveRecordStarter.Initialize( GetConfigSource(), typeof(Blog2) ); Recreate(); Blog2.DeleteAll(); Blog2 blog = new Blog2(); blog.Name = "hammett"; blog.Save(); 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.Save(); }