EditPost() публичный Метод

public EditPost ( Postkey postToEdit, string title, string body ) : System.Result
postToEdit Postkey
title string
body string
Результат System.Result
Пример #1
0
        public void UserIntegration2()
        {
            ClientController cc1 = new ClientController();

            cc1.Login("admin", "admin");

            ClientController cc2 = new ClientController();
            cc2.Register("test2", "123456");
            cc2.Login("test2", "123456");

            ClientController cc3 = new ClientController();
            cc2.Register("test3", "123456");
            cc2.Login("test3", "123456");

            cc2.Post("Cars", "title1", "body1");

            Post[] posts = cc2.GetSubforum("Cars");
            Postkey tmp_postKey = null;
            for (int i = 0; i < posts.Length; i++)
            {
                if (posts[i].Title.Equals("title1"))
                    tmp_postKey = posts[i].Key;
            }

                //try to edit message not by the writer, admin or moderator
                Assert.AreEqual(Result.USER_NOT_FOUND, cc3.EditPost(tmp_postKey, "BadTitle", "BadBody"));

                //try to edit message by admin
                Assert.AreEqual(Result.OK, cc2.EditPost(tmp_postKey, "GoodTitle", "GoodBody"));

                ClientController cc4 = new ClientController();
                cc1.ReplaceAdmin("newAdmin", "newAdminpass"); //the newAdmin will create at the server

                //try to login with the new admin (the registeration was at the replaceAdmin)
                Assert.IsTrue(cc4.Login("newAdmin", "newAdmin"));

                //logic:
                //  if the old admin was just admin (with out any moderator of any subforum)
                //      then he will become regular member.
                //  if the old admin was moderator of any forum
                //      then he will be just the relevant forum moderator (and no admin).

                //try to create subform by non-admin
                Assert.AreEqual(Result.SECURITY_ERROR, cc1.AddSubforum("badbadForum"));

                //try to edit message by non-admin or non moderator
                //   Assert.AreEqual(Result.SECURITY_ERROR, cc1.EditPost("xxx", "yyy"));

                //try to remove non existing subforum (by admin)
                Assert.AreEqual(Result.SECURITY_ERROR, cc4.RemoveSubforum("Forums"));

                //try to remove subforum by non-admin
                Assert.AreEqual(Result.SECURITY_ERROR, cc1.RemoveSubforum("Cars"));
        }