public void UnitTestForumPolicyAdminsGettersSetters() { ForumPolicy fp = new ForumPolicy(); fp.setMaxAdmins(0); Assert.IsTrue(fp.getMaxAdmins() != 0); Assert.IsTrue(fp.getMaxAdmins() == 10); fp.setMaxAdmins(11); Assert.IsTrue(fp.getMaxAdmins() == 11); fp.setMinAdmins(12); Assert.IsTrue(fp.getMinAdmins() != 12); Assert.IsTrue(fp.getMinAdmins() == 1); fp.setMinAdmins(2); Assert.IsTrue(fp.getMinAdmins() == 2); }
public string checkForumPolicy(string forumName, ForumPolicy policy) { List <string> input = new List <string>() { forumName }; if (Constants.isValidInput(input) && policy != null) { lock (o) { int numOfAdmins = _um.getNumOfAdmins(forumName); int maxNumOfModerators = _um.getMaxModerators(forumName); int minNumOfModerators = _um.getMinModerators(forumName); int minModeratorSeniority = _um.getMinModeratorSeniority(forumName); if (numOfAdmins > policy.getMaxAdmins()) { return("Forum " + forumName + " has " + numOfAdmins + " admins. Cannot set max num of admins to " + policy.getMaxAdmins()); } if (numOfAdmins < policy.getMinAdmins()) { return("Forum " + forumName + " has " + numOfAdmins + " admins. Cannot set min num of admins to " + policy.getMinAdmins()); } if (maxNumOfModerators > policy.getMaxModerators()) { return("One of forum " + forumName + " sub forums has " + maxNumOfModerators + " moderators. Cannot set max num of moderators to " + policy.getMaxModerators()); } if (minNumOfModerators < policy.getMinModerators()) { return("One of forum " + forumName + " sub forums has " + minNumOfModerators + " moderators. Cannot set min num of moderators to " + policy.getMinModerators()); } if (minModeratorSeniority < policy.getSeniority()) { return("One of the moderators of forum " + forumName + " has a seniority of " + minModeratorSeniority + " days. Cannot set minimum seniotiry to " + policy.getSeniority()); } return(Constants.SUCCESS); } } return(Constants.INVALID_INPUT); }