ForumClientCore.ClientController.AddModerator C# (CSharp) Method

AddModerator() public method

public AddModerator ( string usernameToAdd, string subforum ) : System.Result
usernameToAdd string
subforum string
return System.Result
        public Result AddModerator(string usernameToAdd, string subforum)
        {
            return netAdaptor.AddModerator(loggedAs, loggedPassword, usernameToAdd, subforum);
        }

Usage Example

Exemplo n.º 1
0
        public void UserIntegration1()
        {
            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");

            //try to add moderator by non-admin
            Assert.AreEqual(Result.OK | Result.INSUFFICENT_PERMISSIONS, cc2.AddModerator("test2", "Cars"));

            cc1.AddModerator("test2", "Cars");

            //to this subforum has already moderator
            Assert.AreEqual(Result.OK, cc1.AddModerator("test2", "Cars"));

            cc2.Post("Cars", "msg2", "body2");
            cc3.Post("Cars", "msg3", "body3");

            //try to replace moderator by non-admin (see: cc2 is the contrller of userName test2)
            Assert.AreEqual(Result.OK | Result.INSUFFICENT_PERMISSIONS | Result.POLICY_REJECTED, cc2.ReplaceModerator("test3", "test2", "Cars"));

            cc1.ReplaceModerator("test3", "test2", "Cars");

            //try to edit message by non-moderator
              //  Assert.AreEqual(Result.SECURITY_ERROR, cc2.EditPost("hehe", "bebe"), "hellow evil world");

            //try to add subform by non-admin
            Assert.AreEqual(Result.INSUFFICENT_PERMISSIONS, cc2.AddSubforum("badSubForum"));

            //try to add subform by admin
            Assert.AreEqual(Result.OK, cc1.AddSubforum("bestForum"));
        }