예제 #1
0
        public void TestVotingReturnsTrueWIthErrorCodesWhenTheAuthorOfTheContentThatThePollIsLinkedToTriesToVote()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            int mockedUserID = 123456;
            IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, mockedUserID, true, false);
            Stub.On(mockedUser).GetProperty("BbcUid").Will(Return.Value("376A83FE-C114-8E06-698B-C66138D635AE"));

            PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
            testPoll.PollID = 123;
            testPoll.RedirectURL = "/dna/actionnetwork/";
            testPoll.AllowAnonymousVoting = true;

            using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, true))
            {
                Stub.On(mockedDataReader).Method("GetInt32").With("itemid").Will(Return.Value(654321));
                using (IDnaDataReader mockedDataReader2 = CreateMockedDanDataReaderForAppContextWithValues("pollgetarticleauthorid", mockedAppContext, true, true))
                {
                    Stub.On(mockedDataReader2).Method("GetInt32").With("userid").Will(Return.Value(mockedUserID));

                    Assert.IsTrue(testPoll.Vote(0), "Vote should return true if a logged in user who's the author of the content the poll is linked to!");
                    Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=6", testPoll.RedirectURL, "Redirect should contain an error code when the author of the content the poll is linked to tries to vote");
                }
            }
        }
예제 #2
0
        public void TestVotingRetrunsTrueIfTheResponseIsOutOfRangeOnAnAnonymousePollAndUserNotLoggedIn_AboveMaxValue()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            int mockedUserID = 123456;
            IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, mockedUserID, false, false);
            Stub.On(mockedUser).GetProperty("BbcUid").Will(Return.Value("376A83FE-C114-8E06-698B-C66138D635AE"));

            PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
            testPoll.PollID = 123;
            testPoll.RedirectURL = @"/dna/actionnetwork/";
            testPoll.AllowAnonymousVoting = true;
            testPoll.SetResponseMinMax(0, 10);

            using (IDnaDataReader reader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, false))
            {
                // Test for value above the maximum
                Assert.IsTrue(testPoll.Vote(11), "Vote should return true if a non logged in users response to an anonymous poll is above the maximum value!");
                Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=2", testPoll.RedirectURL, "Redirect should contain an error code when a logged out users response to an anonymous poll is out of range");
            }
        }
예제 #3
0
 public void TestCreateNewPollWithRange()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     using (IDnaDataReader reader = CreateDataReaderForMockedAppContextForStoreProcedure("CreateNewVote", mockedAppContext))
     {
         PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
         testPoll.SetResponseMinMax(0, 10);
         Assert.IsTrue(testPoll.CreatePoll(), "Creating a poll with a range should return true!");
     }
 }
예제 #4
0
 public void TestVotingReturnsFalseWhenLoggedInUserWithInValidUserIDTriesToVoteOnAnAnonymousVotingPoll()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 0, true, false);
     PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
     testPoll.PollID = 123;
     testPoll.RedirectURL = @"/dna/actionnetwork/";
     testPoll.AllowAnonymousVoting = true;
     Assert.IsFalse(testPoll.Vote(0), "vote should return true if a logged in user with invalid userid tries to vote on an anonymous poll!");
     Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=0", testPoll.RedirectURL, "Redirect should contain an error code when trying to vote on an anonymous poll logged in with invalid user id");
 }
예제 #5
0
        public void Test_ParseRequestURLForCommand_ReturnsTrueForValidConfigPollCommandWithHideSetToOne()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create a logged in editor
            IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123456, true, true);

            // Create the Poll. It won't need a user at this stage
            PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
            testPoll.PollID = 123;

            // Create a mocked data reader
            using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("HidePoll", mockedAppContext, true, true))
            {
                // Create the request object
                IRequest mockedRequest = _mock.NewMock<IRequest>();
                Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("s_redirectto", "Check the redirect for the poll exists").Will(Return.Value("/dna/actionnetwork/"));
                Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("cmd", "Get the command for the poll").Will(Return.Value("hidepoll"));
                Stub.On(mockedRequest).Method("DoesParamExist").With("hide", "Hide/Unhide bool param").Will(Return.Value(true));
                Stub.On(mockedRequest).Method("GetParamIntOrZero").With("hide", "Hide/Unhide bool param").Will(Return.Value(1));

                // Now test that the request is handled correctly
                Assert.IsTrue(testPoll.ParseRequestURLForCommand(mockedRequest), "Parsing the request with config poll command with hide = 1 should not fail!");
                Assert.AreEqual(@"/dna/actionnetwork/", testPoll.RedirectURL, "Redirect should not contain an error code when parsing the request with config poll command with hide = 1!");
            }
        }
예제 #6
0
        public void Test_Statistics_RemoveAStat()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create data reader for load user vote. 
            using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("GetUserVotes", mockedAppContext, true, true))
            {
                Stub.On(mockedDataReader).Method("GetInt32").WithAnyArguments().Will(Return.Value(1));

                Stub.On(mockedAppContext).Method("CreateDnaDataReader").With("GetUserVotes").Will(Return.Value(mockedDataReader));

                // Create a logged in editor
                IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123456, true, true);

                // Create the Poll.
                PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
                testPoll.PollID = 123;

                // add VOTECOUNT and AVERAGERATING
                testPoll.SetContentRatingStatistics(5, 2.2);
                testPoll.SetPollStatistic("votecount", null);

                Assert.IsTrue(testPoll.MakePollXML(false) != null, "MakePollXML should return true when user is logged in and stats set.");

                // Check Xml
                XmlDocument doc = new XmlDocument();
                XmlNode docNode = doc.ImportNode(testPoll.RootElement, true);
                XmlNode statNode = docNode.SelectSingleNode("POLL/STATISTICS");
                Assert.IsNotNull(statNode, "Failed to find POLL/STATISTICS");



                // Check values of Statistics XML
                Assert.IsTrue(statNode.Attributes.Count == 1, "Unexpected attributes in Poll Statistics");
                XmlNode countNode = statNode.Attributes.GetNamedItem("VOTECOUNT");
                Assert.IsNull(countNode, "Found VOTECOUNT attribute when we should not have.");

                XmlNode avgRatingNode = statNode.Attributes.GetNamedItem("AVERAGERATING");
                Assert.IsTrue(avgRatingNode.Value.Equals("2.2"), "AVERAGERATING attribute is not an expected value.");
            }
        }
예제 #7
0
 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");
 }
예제 #8
0
        public void Test_ParseRequestURLForCommand_ReturnsTrueForValidVoteCommand()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create a non logged in user with valid bbcuid
            IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123456, false, false);
            Stub.On(mockedUser).GetProperty("BbcUid").Will(Return.Value("376A83FE-C114-8E06-698B-C66138D635AE"));

            // Create the Poll. It won't need a user at this stage
            PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
            testPoll.SetResponseMinMax(0, 10);
            testPoll.PollID = 123;
            testPoll.AllowAnonymousVoting = true;

            // Mock the procedures the voting 
            using (IDnaDataReader reader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, false))
            {
                using (IDnaDataReader reader2 = CreateDataReaderForMockedAppContextForStoreProcedure("pollanonymouscontentratingvote", mockedAppContext))
                {
                    // Create the request object
                    IRequest mockedRequest = _mock.NewMock<IRequest>();
                    Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("s_redirectto", "Check the redirect for the poll exists").Will(Return.Value("/dna/actionnetwork/"));
                    Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("cmd", "Get the command for the poll").Will(Return.Value("vote"));
                    Stub.On(mockedRequest).Method("TryGetParamIntOrKnownValueOnError").With("response", -1, "Try to get the response for the poll vote").Will(Return.Value(5));

                    // Now test that the request is handled correctly
                    Assert.IsTrue(testPoll.ParseRequestURLForCommand(mockedRequest), "Parsing the request with valid vote command should not fail!");
                    Assert.AreEqual(@"/dna/actionnetwork/", testPoll.RedirectURL, "Redirect should not contain an error code when parsing the request with valid vote command!");
                }
            }
        }
예제 #9
0
 public void TestThatLinkingAnItemToANonLinkPollReturnsTrue()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
     testPoll.PollID = 123;
     using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, false))
     {
         using (IDnaDataReader mockedDataReader2 = CreateMockedDanDataReaderForAppContextWithValues("LinkPollWithItem", mockedAppContext, true, false))
         {
             Assert.IsTrue(testPoll.LinkPollWithItem(123, Poll.ItemType.ITEMTYPE_ARTICLE), "Should return true when adding a link to a poll that hasn't got one already!");
         }
     }
 }
예제 #10
0
 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");
 }
예제 #11
0
 public void TestLinkPollFailsWhenThePollIsAlreadyLinkedToMoreThanOneItem()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
     testPoll.PollID = 123;
     using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, true))
     {
         Assert.IsFalse(testPoll.LinkPollWithItem(123, Poll.ItemType.ITEMTYPE_ARTICLE), "Should return false when poll is already linked to more than one item!");
     }
 }
예제 #12
0
 public void TestLinkPollWithItemReturnsFalseForInvalidPollID()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
     testPoll.PollID = -1;
     Assert.IsFalse(testPoll.LinkPollWithItem(123,Poll.ItemType.ITEMTYPE_ARTICLE),"Should return false when poll id is invalid!");
 }
예제 #13
0
 /// <summary>
 /// Creates a new valid content rating poll
 /// </summary>
 /// <param name="minResponse">The minimum response value</param>
 /// <param name="maxResponse">The maximum response value</param>
 /// <param name="appContext">The App context you want to create the poll in</param>
 /// <returns>The new poll</returns>
 private PollContentRating CreateValidPoll(int minResponse, int maxResponse, IAppContext appContext)
 {
     // Create the app context for the poll to run in
     using (IDnaDataReader reader = CreateDataReaderForMockedAppContextForStoreProcedure("CreateNewVote", appContext))
     {
         PollContentRating testPoll = new PollContentRating(appContext, null);
         testPoll.SetResponseMinMax(0, 10);
         if (!testPoll.CreatePoll())
         {
             return null;
         }
         return testPoll;
     }
 }
예제 #14
0
        public void TestVotingReturnsTrueWithNoErrorsWhenAnonLoggedInUserWithValidResponseVotesOnAnAnonymousPoll()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            int mockedUserID = 123456;
            IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, mockedUserID, false, false);
            Stub.On(mockedUser).GetProperty("BbcUid").Will(Return.Value("376A83FE-C114-8E06-698B-C66138D635AE"));

            PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
            testPoll.PollID = 123;
            testPoll.RedirectURL = @"/dna/actionnetwork/";
            testPoll.AllowAnonymousVoting = true;
            testPoll.SetResponseMinMax(0, 10);

            using (IDnaDataReader reader = CreateMockedDanDataReaderForAppContextWithValues("pollgetitemids", mockedAppContext, true, false))
            {
                using (IDnaDataReader reader2 = CreateDataReaderForMockedAppContextForStoreProcedure("pollanonymouscontentratingvote", mockedAppContext))
                {
                    // Test for value below the minimum
                    Assert.IsTrue(testPoll.Vote(5), "Vote should return true if a logged in users response to an anonymous poll is within voting range!");
                    Assert.AreEqual(@"/dna/actionnetwork/", testPoll.RedirectURL, "Redirect should not contain an error code when logged in user votes with an inrange response!");
                }
            }
        }
예제 #15
0
 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");
     }
 }
예제 #16
0
        public void Test_ParseRequestURLForCommand_FailsWithNoRedirect()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create the request object
            IRequest mockedRequest = _mock.NewMock<IRequest>();
            Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("s_redirectto", "Check the redirect for the poll exists").Will(Return.Value(""));

            // Create the Poll. It won't need a user at this stage
            PollContentRating testPoll = new PollContentRating(mockedAppContext, null);

            // Now test that the request is handled correctly
            Assert.IsFalse(testPoll.ParseRequestURLForCommand(mockedRequest),"Parsing the request with no redirect should fail!");
            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 contain an error about a missing redirect");
        }
예제 #17
0
 public void TestVoteReturnsTrueWhenNoRedirectGiven()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
     testPoll.PollID = 0;
     testPoll.RedirectURL = "";
     Assert.IsTrue(testPoll.Vote(0), "Vote with no redirect value should return true!");
     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 contain an error about a missing redirect");
 }
예제 #18
0
        public void Test_ParseRequestURLForCommand_ReturnsTrueForRemoveVoteCommand()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create the Poll. It won't need a user at this stage
            PollContentRating testPoll = new PollContentRating(mockedAppContext, null);

            // Create the request object
            IRequest mockedRequest = _mock.NewMock<IRequest>();
            Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("s_redirectto", "Check the redirect for the poll exists").Will(Return.Value("/dna/actionnetwork/"));
            Stub.On(mockedRequest).Method("GetParamStringOrEmpty").With("cmd", "Get the command for the poll").Will(Return.Value("removevote"));

            // Now test that the request is handled correctly
            Assert.IsTrue(testPoll.ParseRequestURLForCommand(mockedRequest), "Parsing the request with remove vote command should not fail!");
            Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=2", testPoll.RedirectURL, "Redirect should contain an error code when parsing the request with remove command!");
        }
예제 #19
0
 public void TestVoteReturnsFalseWhenRedirectGivenAndPollIDIsInvalid()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext,null);
     testPoll.PollID = 0;
     testPoll.RedirectURL = @"/dna/actionnetwork/";
     Assert.IsFalse(testPoll.Vote(0), "vote should return false if the poll id is not valid!");
     Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=3", testPoll.RedirectURL, "Redirect should contain an error code when trying to hide a poll with an editor");
 }
예제 #20
0
        public void Test_Statistics_BlankName()
        {
            // Create the app context for the poll to run in
            IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();

            // Create data reader for load user vote. 
            using (IDnaDataReader mockedDataReader = CreateMockedDanDataReaderForAppContextWithValues("GetUserVotes", mockedAppContext, true, true))
            {
                Stub.On(mockedDataReader).Method("GetInt32").WithAnyArguments().Will(Return.Value(1));
                Stub.On(mockedAppContext).Method("CreateDnaDataReader").With("GetUserVotes").Will(Return.Value(mockedDataReader));

                // Create a logged in editor
                IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123456, true, true);

                // Create the Poll.
                PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
                testPoll.PollID = 123;

                // try to set stat with invalid name
                testPoll.SetPollStatistic("", "blah-value");

                Assert.IsTrue(testPoll.MakePollXML(false) != null, "MakePollXML should return true when user is logged in and stats set.");

                XmlDocument doc = new XmlDocument();
                XmlNode docNode = doc.ImportNode(testPoll.RootElement, true);
                XmlNode errorNode = docNode.SelectSingleNode("ERROR");
                Assert.IsNotNull(errorNode, "Failed to find ERROR element");
                XmlNode errorAttribute = errorNode.Attributes.GetNamedItem("TYPE");
                Assert.IsTrue(errorAttribute.Value.Equals("2"), "Unexpected value for error code.");

                XmlNode statNode = docNode.SelectSingleNode("POLL/STATISTICS");
                Assert.IsNull(statNode, "Inexpected POLL/STATISTICS element");
            }
        }
예제 #21
0
 public void TestVotingReturnsTrueWhenUserNotLoggedInVotingOnANonAnonymousPoll()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     IUser mockedUser = CreateMockedUserForMockedAppContext(mockedAppContext, 123, false, false);
     PollContentRating testPoll = new PollContentRating(mockedAppContext, mockedUser);
     testPoll.PollID = 123;
     testPoll.RedirectURL = @"/dna/actionnetwork/";
     testPoll.AllowAnonymousVoting = false;
     Assert.IsTrue(testPoll.Vote(0), "vote should return true if a non logged in user tries to vote on a non anonymous poll!");
     Assert.AreEqual(@"/dna/actionnetwork/?PollErrorCode=4", testPoll.RedirectURL, "Redirect should contain an error code when trying to vote on a non anonymous poll not logged in");
 }
예제 #22
0
        /// <summary>
        /// AddPollXml - Delegates responsibility of producing standard Poll Xml to the Poll Class.
        /// Only produces Poll Xml where a valid Poll exists in the resultset.
        /// </summary>
        /// <param name="dataReader">Record set containing the data</param>
        /// <param name="parent">Parent node to add the xml to</param>
        private void AddPollXml(IDnaDataReader dataReader, XmlNode parent)
        {
            if (dataReader.DoesFieldExist("CRPollID"))
            {
                int pollId = dataReader.GetInt32NullAsZero("CRPollID");
                if (pollId > 0)
                {
                    PollContentRating poll = new PollContentRating(this.InputContext, this.InputContext.ViewingUser);

                    poll.PollID = dataReader.GetInt32NullAsZero("CRPollID");
                    poll.Hidden = dataReader.GetInt32NullAsZero("Hidden") != 0;
                    int voteCount = dataReader.GetInt32NullAsZero("CRVoteCount");
                    double avgRating = dataReader.GetDoubleNullAsZero("CRAverageRating");
                    poll.SetContentRatingStatistics(voteCount, avgRating);
                    XmlNode node = poll.MakePollXML(false);
                    if (node != null)
                    {
                        parent.AppendChild(ImportNode(node));
                    }
                }
            }
        }
예제 #23
0
 public void TestCreateNewPollFailsWithValidPollID()
 {
     // Create the app context for the poll to run in
     IAppContext mockedAppContext = CreateMockedAppContextAndDiagnostics();
     PollContentRating testPoll = new PollContentRating(mockedAppContext, null);
     testPoll.PollID = 1;
     Assert.IsFalse(testPoll.CreatePoll(), "Creating a poll with a valid poll id should return false!");
 }