Пример #1
0
        public void ProcessRiskModAssessment_PubMethodA_InReplyTo_Risky()
        {
            using (new TransactionScope())
            {
                using (IDnaDataReader reader = StoredProcedureReader.Create("", ConnectionDetails))
                {
                    ClearBIEventQueue(reader);

                    // Create a risk mod entry
                    var info = new RiskModThreadEntryQueueInfo();
                    RiskModOn_PubMethodA_Unmoderated_InReplyTo_internal(info);

                    int riskModId = GetLatestRiskModThreadEntryQueueId(reader);

                    GenerateBIEvents(reader);
                    Assert.IsTrue(CheckEventET_POSTNEEDSRISKASSESSMENTIsInBIEventQueue(reader, riskModId, 42));

                    bool? isRisky = null;
                    CheckRiskModThreadEntryQueue(reader, info.threadentryid, 'A', isRisky, null, info.siteid, info.forumid, info.inReplyToThread, 42, "the furry one", info.inReplyTo, "The Cabinet", info.posttext, 1, "testip", testGUID.ToString(), DateTime.Now, 1, 0, null, 0, 0, 0, null, 0);

                    int latestThreadId = GetLatestThreadId(reader);
                    int latestThreadEntryId = GetLatestThreadEntryId(reader);

                    int? newThreadId, newThreadEntryId;
                    RiskMod_ProcessRiskAssessmentForThreadEntry(reader, riskModId, "Risky", out newThreadId, out newThreadEntryId);

                    isRisky = true;
                    TestDate td = new TestDate() { TestDateTime = DateTime.Now };
                    CheckRiskModThreadEntryQueue(reader, newThreadEntryId, 'A', isRisky, td, info.siteid, info.forumid, info.inReplyToThread, 42, "the furry one", info.inReplyTo, "The Cabinet", info.posttext, 1, "testip", testGUID.ToString(), DateTime.Now, 1, 0, null, 0, 0, 0, null, 0);

                    CheckLatestThreadMod(reader, info.forumid, info.inReplyToThread, newThreadEntryId, null, 0, "[The post will be published after moderation. Queued by risk moderation]", info.siteid, 1);

                    int modId = GetLatestThreadModId(reader);
                    CheckLatestPremodPostings(reader, modId, 42, info.forumid, info.inReplyToThread, info.inReplyTo, info.posttext, 1, info.siteid, 0, riskModId);

                    // check no mod queue entry was created
                    Assert.AreEqual(latestThreadId, GetLatestThreadId(reader));
                    Assert.AreEqual(latestThreadEntryId, GetLatestThreadEntryId(reader));
                }
            }
        }
Пример #2
0
 void TestNullableDateField(IDnaDataReader reader, string fieldName, TestDate expected)
 {
     if (reader.IsDBNull(fieldName))
         Assert.IsNull(expected);
     else
         Assert.IsTrue(expected.CheckDate(reader.GetDateTime(fieldName)));
 }
Пример #3
0
        public void ProcessRiskModAssessment_PubMethodB_NewThread_Risky()
        {
            using (new TransactionScope())
            {
                using (IDnaDataReader reader = StoredProcedureReader.Create("", ConnectionDetails))
                {
                    ClearBIEventQueue(reader);

                    // Create a risk mod entry
                    var info = new RiskModThreadEntryQueueInfo();
                    RiskModOn_PubMethodB_Unmoderated_NewThread_internal(info);

                    int riskModId = GetLatestRiskModThreadEntryQueueId(reader);

                    GenerateBIEvents(reader);
                    Assert.IsTrue(CheckEventET_POSTNEEDSRISKASSESSMENTIsInBIEventQueue(reader, riskModId, 42));

                    bool? isRisky = null;
                    CheckRiskModThreadEntryQueue(reader, info.threadentryid, 'B', isRisky, null, info.siteid, info.forumid, info.threadid, 42, "the furry one", null, "The Cabinet", info.posttext, 1, "testip", testGUID.ToString(), DateTime.Now, 1, 0, null, 0, 0, 0, null, 0);

                    int? newThreadId, newThreadEntryId;
                    RiskMod_ProcessRiskAssessmentForThreadEntry(reader, riskModId, "Risky", out newThreadId, out newThreadEntryId);

                    Assert.IsNull(newThreadId);
                    Assert.IsNull(newThreadEntryId);

                    isRisky = true;
                    TestDate td = new TestDate() { TestDateTime = DateTime.Now };
                    CheckRiskModThreadEntryQueue(reader, info.threadentryid, 'B', isRisky, td, info.siteid, info.forumid, info.threadid, 42, "the furry one", null, "The Cabinet", info.posttext, 1, "testip", testGUID.ToString(), DateTime.Now, 1, 0, null, 0, 0, 0, null, 0);

                    // Check that an entry ended up in the thread mod queue
                    CheckLatestThreadMod(reader, info.forumid, info.threadid, info.threadentryid, null, 0, "[The post was published before being queued by risk moderation]", info.siteid, 0);
                }
            }
        }
Пример #4
0
        void CheckRiskModThreadEntryQueue(IDnaDataReader reader, int? ThreadEntryId, char PublishMethod, bool? IsRisky, TestDate DateAssessed, int SiteId, int ForumId, int? ThreadId, int UserId, string UserName, int? InReplyTo, string Subject, string Text, byte PostStyle, string IPAddress, string BBCUID, DateTime EventDate, byte AllowEventEntries, int NodeId, int? QueueId, int ClubId, byte IsNotable, byte IsComment, string ModNotes, byte IsThreadedComment)
        {
            reader.ExecuteWithinATransaction(@"SELECT rm.*
                                        FROM RiskModThreadEntryQueue rm
                                        WHERE RiskModThreadEntryQueueId=" + GetLatestRiskModThreadEntryQueueId(reader));
            reader.Read();

            // Nasty tweak.  The RiskModThreadEntryQueue table always stores undefined ThreadId and ThreadEntryId values
            // as NULL.  We treat zero values as NULL for comparision purposes 
            ThreadId = NullIf(ThreadId, 0);
            ThreadEntryId = NullIf(ThreadEntryId, 0);
            
            TestNullableIntField(reader, "ThreadEntryId", ThreadEntryId);

            TestPublishMethod(reader, PublishMethod);

            TestNullableBoolField(reader, "IsRisky", IsRisky);

            TestNullableDateField(reader, "DateAssessed", DateAssessed);

            Assert.AreEqual(SiteId,reader.GetInt32("SiteId"));
            Assert.AreEqual(ForumId,reader.GetInt32("ForumId"));

            TestNullableIntField(reader, "ThreadId", ThreadId);

            Assert.AreEqual(UserId,reader.GetInt32("UserId"));

            Assert.AreEqual(UserName, reader.GetString("UserName"));

            TestNullableIntField(reader, "InReplyTo", InReplyTo);

            Assert.AreEqual(Subject,reader.GetString("Subject"));
            Assert.AreEqual(Text,reader.GetString("Text"));
            Assert.AreEqual(PostStyle, reader.GetByte("PostStyle"));
            Assert.AreEqual(IPAddress,reader.GetString("IPAddress"));
            Assert.AreEqual(BBCUID,reader.GetGuidAsStringOrEmpty("BBCUID"));

            //Assert.AreEqual(EventDate,reader.GetInt32("EventDate"));
            Assert.AreEqual(AllowEventEntries,reader.GetByte("AllowEventEntries"));
            //Assert.AreEqual(NodeId,reader.GetInt32("NodeId"));
            TestNullableIntField(reader, "QueueId", QueueId);
            Assert.AreEqual(ClubId,reader.GetInt32("ClubId"));
            Assert.AreEqual(IsNotable, reader.GetByte("IsNotable"));
            Assert.AreEqual(IsComment, reader.GetByte("IsComment"));
            TestNullableStringField(reader, "ModNotes", ModNotes);
            Assert.AreEqual(IsThreadedComment, reader.GetByte("IsThreadedComment"));

            reader.Close();
        }