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 ); }
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 ); }
/// <summary> /// Libera um <see cref="ISessionScope"/> do <c>ActiveRecord</c>. /// É chamado toda vez que uma requisição é finalizada, no evento /// <see cref="HttpApplication.EndRequest"/>. /// </summary> protected virtual void DisposeActiveRecordSessionScope(SessionScope scope) { scope.Dispose(); }