예제 #1
0
 // check if user <@param user name> is the publisher of the discussion d.
 public static bool checkPublisherAuthorization(Discussion d, string userName, string password)
 {
     User publisher = d.publisher;
     if (publisher != null && publisher.password == password && publisher.isLogged())
         return true;
     return false;
 }
예제 #2
0
 public Comment(string content, User user, Discussion parentDiscussion)
 {
     this.content = content;
     this.publishDate = DateTime.Now;
     this.publisher = user;
     this.parentDiscussion = parentDiscussion;
 }
예제 #3
0
 // POCO constructor
 public Discussion(Discussion d)
 {
     this.discussionId = d.discussionId;
     this.title = d.title;
     this.content = d.content;
     this.publishDate = d.publishDate;
     this.publisher = new User(d.publisher);
     this.comments = null;
     this.parentSubForum = null;
 }
        private int testGetResponsersForSingleUser()
        {
            {
                int testNum = 0;

                List<User> res;

                /* success tests */
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User[] users = new User[10];
                    for(int i=0; i<10; i++)
                        users[i] = this.bridge.register(forum.forumId, "user"+i, "pswd"+i, "", "");

                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[5].userName);
                    AssertTrue(res.Count == 0);

                    for (int i = 0; i < 10; i++)
                        this.bridge.login(forum.forumId, users[i].userName, users[i].password);
                    Discussion[] discussions = new Discussion[30];
                    for (int i = 0; i < 30; i++)
                        discussions[i] = this.bridge.createNewDiscussion(users[i % 10].userName, users[i % 10].password, forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[5].userName);
                    AssertTrue(res.Count == 0);

                    for (int i = 0; i < 10; i++)
                        this.bridge.createNewComment(users[i].userName, users[i].password, forum.forumId, subForum.subForumId, discussions[0].discussionId, "no content");

                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[0].userName);
                    AssertTrue(res.Count == 9); // 9- because it doesn't include user[0] (publisher)

                    testNum++;
                }
                catch { failMsg(testNum); }

                this.bridge.reset();

                /* failure tests */

                // wrong userName
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User[] users = new User[10];
                    for (int i = 0; i < 10; i++)
                        users[i] = this.bridge.register(forum.forumId, "user" + i, "pswd" + i, "", "");

                    res = this.bridge.getResponsersForSingleUser("wrong user", ADMIN_PSWD, forum.forumId, users[5].userName);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong password
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User[] users = new User[10];
                    for (int i = 0; i < 10; i++)
                        users[i] = this.bridge.register(forum.forumId, "user" + i, "pswd" + i, "", "");

                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, "wrong pass", forum.forumId, users[5].userName);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong forumId
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User[] users = new User[10];
                    for (int i = 0; i < 10; i++)
                        users[i] = this.bridge.register(forum.forumId, "user" + i, "pswd" + i, "", "");

                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, 300000000, users[5].userName);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong username of required user
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User[] users = new User[10];
                    for (int i = 0; i < 10; i++)
                        users[i] = this.bridge.register(forum.forumId, "user" + i, "pswd" + i, "", "");

                    res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "wrong user");
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                return testNum;
            }
        }
        private int testGetNumOfCommentsSubForum()
        {
            {
                this.bridge.reset();
                int testNum = 0;

                int res;

                /* success tests */
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                    User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                    AssertTrue(res==0);

                    user1 = this.bridge.login(forum.forumId, "user1", "pswd1");
                    user2 = this.bridge.login(forum.forumId, "user2", "pswd2");
                    Discussion[] discussions = new Discussion[100];
                    for (int i=0; i<100; i++)
                        discussions[i] = this.bridge.createNewDiscussion("user1", "pswd1", forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                    AssertTrue(res == 100);

                    for (int i = 1; i <= 50; i++)
                    {
                        this.bridge.createNewComment("user1", "pswd1", forum.forumId, subForum.subForumId, discussions[35].discussionId, "no content");
                        this.bridge.createNewComment("user2", "pswd2", forum.forumId, subForum.subForumId, discussions[55].discussionId, "no content");
                        this.bridge.createNewComment("user2", "pswd2", forum.forumId, subForum.subForumId, discussions[75].discussionId, "no content");
                    }
                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                    AssertTrue(res == 250);

                    testNum++;
                }
                catch { failMsg(testNum); }

                this.bridge.reset();

                /* failure tests */

                // wrong userName
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                    User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                    res = this.bridge.getNumOfCommentsSubForum("wrong user", ADMIN_PSWD, forum.forumId, subForum.subForumId);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong password
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                    User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, "wrong pass", forum.forumId, subForum.subForumId);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong forumId
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                    User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, -2, subForum.subForumId);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                // wrong subForumId
                try
                {
                    this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                    Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", ADMIN_NAME, ADMIN_PSWD, Forum.RegPolicy.NONE);
                    this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                    SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                    User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                    User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                    res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, -5);
                    failMsg(testNum);
                }
                catch { testNum++; }

                this.bridge.reset();

                return testNum;
            }
        }
        /* Large Scalabiliy - lots of comments and discussions */
        private int LargeScalability()
        {
            int testNum = 0;

            /* testGetNumOfCommentsSubForum */
            try
            {
                int res;

                const int DISCUSSIONS_NUMBER = 100;
                const int COMMENTS_NUMBER = 20;
                this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", "mngr", "mngrPswd", Forum.RegPolicy.NONE);
                this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(res == 0);

                user1 = this.bridge.login(forum.forumId, "user1", "pswd1");
                user2 = this.bridge.login(forum.forumId, "user2", "pswd2");
                Discussion[] discussions = new Discussion[DISCUSSIONS_NUMBER];
                for (int i = 0; i < DISCUSSIONS_NUMBER; i++)
                    discussions[i] = this.bridge.createNewDiscussion("user1", "pswd1", forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(res == DISCUSSIONS_NUMBER);

                for (int i = 1; i <= COMMENTS_NUMBER; i++)
                {
                    this.bridge.createNewComment("user1", "pswd1", forum.forumId, subForum.subForumId, discussions[35].discussionId, "no content");
                    this.bridge.createNewComment("user2", "pswd2", forum.forumId, subForum.subForumId, discussions[55].discussionId, "no content");
                    this.bridge.createNewComment("user2", "pswd2", forum.forumId, subForum.subForumId, discussions[75].discussionId, "no content");
                }
                res = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(res == COMMENTS_NUMBER * 3 + DISCUSSIONS_NUMBER);

                testNum++;
            }
            catch { failMsg(testNum++); }

            this.bridge.reset();

            ///* getNumOfCommentsSingleUser */
            try
            {
                int res;

                const int DISCUSSIONS_NUMBER = 10;
                const int COMMENTS_NUMBER = 25;
                this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", "mngr", "mngrPswd", Forum.RegPolicy.NONE);
                this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                User user1 = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");

                res = this.bridge.getNumOfCommentsSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, user1.userName);
                AssertTrue(res == 0);

                user1 = this.bridge.login(forum.forumId, "user1", "pswd1");
                user2 = this.bridge.login(forum.forumId, "user2", "pswd2");
                Discussion[] discussions1 = new Discussion[DISCUSSIONS_NUMBER];
                Discussion[] discussions2 = new Discussion[DISCUSSIONS_NUMBER];
                for (int i = 0; i < DISCUSSIONS_NUMBER; i++)
                {
                    discussions1[i] = this.bridge.createNewDiscussion(user1.userName, user1.password, forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                    discussions2[i] = this.bridge.createNewDiscussion(user2.userName, user2.password, forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                }
                res = this.bridge.getNumOfCommentsSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, user1.userName);
                AssertTrue(res == DISCUSSIONS_NUMBER);
                res = this.bridge.getNumOfCommentsSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, user2.userName);
                AssertTrue(res == DISCUSSIONS_NUMBER);

                for (int i = 1; i <= COMMENTS_NUMBER; i++)
                {
                    this.bridge.createNewComment(user1.userName, user1.password, forum.forumId, subForum.subForumId, discussions1[DISCUSSIONS_NUMBER- 3].discussionId, "no content");
                    this.bridge.createNewComment(user2.userName, user2.password, forum.forumId, subForum.subForumId, discussions2[DISCUSSIONS_NUMBER - 5].discussionId, "no content");
                    this.bridge.createNewComment(user2.userName, user2.password, forum.forumId, subForum.subForumId, discussions2[DISCUSSIONS_NUMBER - 9].discussionId, "no content");
                }
                res = this.bridge.getNumOfCommentsSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, user1.userName);
                AssertTrue(res == DISCUSSIONS_NUMBER + COMMENTS_NUMBER);
                res = this.bridge.getNumOfCommentsSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, user2.userName);
                AssertTrue(res == DISCUSSIONS_NUMBER + 2 * COMMENTS_NUMBER);

                testNum++;
            }
            catch { failMsg(testNum++); }

            this.bridge.reset();

            ///* getResponsersForSingleUser */
            try
            {
                List<User> res;

                const int USERS_NUMBER = 10;
                const int DISCUSSSION_NEMBER = 25;
                this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", "mngr", "mngrPswd", Forum.RegPolicy.NONE);
                this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                User[] users = new User[USERS_NUMBER];
                for (int i = 0; i < USERS_NUMBER; i++)
                    users[i] = this.bridge.register(forum.forumId, "user" + i, "pswd" + i, "", "");

                res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[5].userName);
                AssertTrue(res.Count == 0);

                for (int i = 0; i < USERS_NUMBER; i++)
                    this.bridge.login(forum.forumId, users[i].userName, users[i].password);
                Discussion[] discussions = new Discussion[DISCUSSSION_NEMBER];
                for (int i = 0; i < DISCUSSSION_NEMBER; i++)
                    discussions[i] = this.bridge.createNewDiscussion(users[i % USERS_NUMBER].userName, users[i % USERS_NUMBER].password, forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[5].userName);
                AssertTrue(res.Count == 0);

                for (int i = 0; i < USERS_NUMBER; i++)
                    this.bridge.createNewComment(users[i].userName, users[i].password, forum.forumId, subForum.subForumId, discussions[0].discussionId, "no content");

                res = this.bridge.getResponsersForSingleUser(ADMIN_NAME, ADMIN_PSWD, forum.forumId, users[0].userName);
                AssertTrue(res.Count == USERS_NUMBER - 1); //  (USERS_NUMBER - 1) - because it doesn't include user[0] (publisher)

                testNum++;
            }
            catch { failMsg(testNum++); }

            this.bridge.reset();

            return testNum;
        }
예제 #7
0
        internal Discussion createNewDiscussion(string title, string content, User user, ForumGeneratorContext db, HashSet<string> stopWords)
        {
            List<string> keyWords = parseKeyWords(content, stopWords);
            if (keyWords != null && keyWords.Count > 0)
            {
                if (isClassifies())
                {
                    checkRelevantContent(keyWords);
                }
                else
                    this.vocabulary = TextClassifier.addToVocabulary(keyWords, this.vocabulary);
            }

            Discussion newDiscussion = new Discussion(title, content, user, this);
            this.discussions.Add(newDiscussion);
            db.Discussions.Add(newDiscussion);
            db.SaveChanges();

            return newDiscussion;
        }
예제 #8
0
        private void scenario2()
        {
            /* Initialization of uniqe string names*/

            string SUB_FORUM1 = "subForum" + random.Next(min, max);
            string USER_1 = "user" + random.Next(min, max);
            string PASSWORD_1 = "pswd" + random.Next(min, max);
            string DISCUSSION_1 = "discussion" + random.Next(min, max);
            string NO_CONTENT = "no content";

            // num = 2;//random.Next(min, max);
            string USER_2 = "user" + random.Next(min, max);
            string PASSWORD_2 = "pswd" + random.Next(min, max);

            try
            {
                //   Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, FORUM_NAME1, ADMIN_NAME, ADMIN_PSWD,Forum.RegPolicy.NONE);
                this.bridge.login(Unitedforum.forumId, ADMIN_NAME, ADMIN_PSWD);
                SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, SUB_FORUM1);
                User user = this.bridge.register(Unitedforum.forumId, USER_1, PASSWORD_1, "", "");
                Discussion d = this.bridge.createNewDiscussion(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId, DISCUSSION_1, NO_CONTENT);

                this.bridge.login(Unitedforum.forumId, USER_1, PASSWORD_1);
                for (int i = 1; i <= 10; i++)
                {
                    this.bridge.createNewComment(USER_1, PASSWORD_1, Unitedforum.forumId, subForum.subForumId, d.discussionId, NO_CONTENT);
                }
                Boolean logoutAns = this.bridge.logout(Unitedforum.forumId, user.userName, user.password);
                AssertFalse(user.isLoggedIn);
                AssertTrue(logoutAns);

                int num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId);

                this.bridge.login(Unitedforum.forumId, ADMIN_NAME, ADMIN_PSWD);
                User user2 = this.bridge.register(Unitedforum.forumId, USER_2, PASSWORD_2, "", "");
                user2 = this.bridge.login(Unitedforum.forumId, USER_2, PASSWORD_2);

                for (int i = 1; i <= 10; i++)
                {
                    this.bridge.createNewComment(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId, d.discussionId, NO_CONTENT);
                }
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId);

                d = this.bridge.editDiscussion(Unitedforum.forumId, subForum.subForumId, d.discussionId, ADMIN_NAME, ADMIN_PSWD, "brand new content");
                AssertEquals(d.content, "brand new content");

                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId);

                Discussion[] discussions = new Discussion[100];
                for (int i = 1; i <= 10; i++)
                    discussions[i] = this.bridge.createNewDiscussion(USER_2, PASSWORD_2, Unitedforum.forumId, subForum.subForumId, "discussion" + i, NO_CONTENT);
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId);

                for (int i = 1; i <= 10; i++)
                    d = this.bridge.editDiscussion(Unitedforum.forumId, subForum.subForumId, discussions[i].discussionId, USER_2, PASSWORD_2, "brand new content" + i);
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, Unitedforum.forumId, subForum.subForumId);

                Console.WriteLine("finished scenario2 \n");

            }
            catch
            {
                failMsg(testNum);
                failed2 = true;
            }

            //this.bridge.reset();
        }
        private int advancedTest1()
        {
            int testNum = 1;
            try
            {
                this.bridge.superUserLogin(SU_NAME, SU_PSWD);
                Forum forum = this.bridge.createNewForum(SU_NAME, SU_PSWD, "forum1", "mngr", "mngrPswd", Forum.RegPolicy.NONE);
                this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                SubForum subForum = this.bridge.createNewSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, "subForum1");
                User user = this.bridge.register(forum.forumId, "user1", "pswd1", "", "");
                Discussion d = this.bridge.createNewDiscussion(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId, "discussion1", "no content");
                this.bridge.login(forum.forumId, "user1", "pswd1");

                for (int i = 1; i <= 10; i++)
                {
                    this.bridge.createNewComment("user1", "pswd1", forum.forumId, subForum.subForumId, d.discussionId, "no content");
                }
                Boolean logoutAns = this.bridge.logout(forum.forumId, user.userName, user.password);
                AssertFalse(user.isLoggedIn);
                AssertTrue(logoutAns);

                int num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(num_of_comments == 11);

                this.bridge.login(forum.forumId, ADMIN_NAME, ADMIN_PSWD);
                User user2 = this.bridge.register(forum.forumId, "user2", "pswd2", "", "");
                user2 = this.bridge.login(forum.forumId, "user2", "pswd2");

                for (int i = 1; i <= 100; i++)
                {
                    this.bridge.createNewComment(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId, d.discussionId, "no content");
                }
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(num_of_comments == 111);

                d = this.bridge.editDiscussion(forum.forumId, subForum.subForumId, d.discussionId, ADMIN_NAME, ADMIN_PSWD, "brand new content");
                AssertEquals(d.content, "brand new content");

                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(num_of_comments == 111);

                Discussion[] discussions = new Discussion[100];
                for (int i = 0; i <= 99; i++)
                    discussions[i] = this.bridge.createNewDiscussion("user2", "pswd2", forum.forumId, subForum.subForumId, "discussion" + i, "no content");
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(num_of_comments == 211);

                for (int i = 1; i <= 10; i++)
                    d = this.bridge.editDiscussion(forum.forumId, subForum.subForumId, discussions[i].discussionId, "user2", "pswd2", "brand new content" + i);
                num_of_comments = this.bridge.getNumOfCommentsSubForum(ADMIN_NAME, ADMIN_PSWD, forum.forumId, subForum.subForumId);
                AssertTrue(num_of_comments == 211);

            }
            catch { failMsg(testNum++); }

            this.bridge.reset();
            return testNum++;
        }