public void TestHidePollFailsWhenUserLoggedInButNotEditor() { // Create the app context for the poll to run in IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics(); IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123, true, false); PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser); testPoll.PollID = 123; testPoll.RedirectURL = @"dna/actionnetwork/"; Assert.IsTrue(testPoll.HidePoll(true), "Hide poll should return true when the user is not an editor."); Assert.AreEqual(@"dna/actionnetwork/?PollErrorCode=5", testPoll.RedirectURL, "Redirect should contain an error code when trying to hide a poll with no logged in user"); }
public void TestHidePollReturnsTrueWhenLoggedInAsEditor() { // Create the app context for the poll to run in IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics(); IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123, true, true); PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser); testPoll.PollID = 123; testPoll.RedirectURL = @"dna/actionnetwork/"; using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("HidePoll", mockedAppContext, true, true)) { Assert.IsTrue(testPoll.HidePoll(true), "Hide poll should return false when the user is not an editor."); Assert.AreEqual(@"dna/actionnetwork/", testPoll.RedirectURL, "Redirect should not contain an error code when trying to hide a poll with an editor"); } }
public void TestHidePollFailsWhenNoRedirectGiven() { // Create the app context for the poll to run in IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics(); PollContentRating testPoll = new PollContentRating(mockedAppContext, null); testPoll.PollID = 123; Assert.IsTrue(testPoll.HidePoll(true), "Hide poll should return true when no redirect url given."); Assert.AreEqual(@"<ERROR TYPE=""ERRORCODE_BADPARAMS""><ERRORMESSAGE>'s_redirectto' not set by skin</ERRORMESSAGE></ERROR>", testPoll.RootElement.InnerXml.ToString(), "The xml for the poll should not contain an error about a missing redirect"); }