コード例 #1
0
        public void TestTakeOwnershipDisallowed()
        {
            Blog blog = new Blog();
            blog.Account = _user;
            blog.Created = DateTime.UtcNow;
            blog.Description = Guid.NewGuid().ToString();
            blog.Name = Guid.NewGuid().ToString();
            Session.Save(blog);
            Session.Flush();

            Account user2 = CreateUser();
            using (new Impersonator(new UserContext(user2)))
            {
                try
                {
                    blog.Description = Guid.NewGuid().ToString();
                    blog.Account = user2;
                    Session.Save(blog);
                    Session.Flush();
                }
                finally
                {
                    // delete temp user
                    DeleteUser(user2);
                    using (new Impersonator(new UserContext(blog.Account)))
                    {
                        // delete blog
                        Blog blogCopy = Session.Load<Blog>(blog.Id);
                        Session.Delete(blogCopy);
                        Session.Flush();
                    }
                }
            }
        }
コード例 #2
0
 public void DeleteBlog(Blog instance)
 {
     using (new Impersonator(new UserContext(instance.Account)))
     {
         Blog instanceCopy = Session.Load<Blog>(instance.Id);
         Session.Delete(instanceCopy);
         Session.Flush();
     }
 }
コード例 #3
0
ファイル: BlogClassACL.cs プロジェクト: dblock/codeproject
 public BlogClassACL(Blog instance)
 {
     // allow every authenticated user to create a blog
     this.Add(new ACLAuthenticatedAllowCreate());
     // allow everyone to get information about this blog
     this.Add(new ACLEveryoneAllowRetrieve());
     // the owner has full privileges
     this.Add(new ACLAccount(instance.Account, DataOperation.All));
 }
コード例 #4
0
 public void TestCreateDelete()
 {
     Blog blog = new Blog();
     blog.Account = _user;
     blog.Created = DateTime.UtcNow;
     blog.Description = Guid.NewGuid().ToString();
     blog.Name = Guid.NewGuid().ToString();
     Session.Save(blog);
     Session.Delete(blog);
 }
コード例 #5
0
 public Blog CreateBlog()
 {
     Blog instance = new Blog();
     instance.Account = _user;
     instance.Created = DateTime.UtcNow;
     instance.Description = Guid.NewGuid().ToString();
     instance.Name = Guid.NewGuid().ToString();
     Session.Save(instance);
     Session.Flush();
     return instance;
 }
コード例 #6
0
 public override void SetUp()
 {
     base.SetUp();
     _blog = CreateBlog();
 }