Пример #1
0
 public void StartUp()
 {
     SnapshotInitialisation.RestoreFromSnapshot();
     DnaTestURLRequest testUserReq = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
     testUserReq.SetCurrentUserNormal();
     clearFromDB(testUserReq);
     using (FullInputContext inputContext = new FullInputContext(""))
     {
         inputContext.SendSignal("action=recache-groups");
     }
 }
Пример #2
0
 public void StartUp()
 {
     Console.WriteLine("Signal Test StartUp");
     // First get the open close times for the h2g2 site
     SnapshotInitialisation.RestoreFromSnapshot();
     SetSiteEmergencyClosed(false);
     using (FullInputContext inputContext = new FullInputContext(false))
     {
         inputContext.SendSignal("action=recache-site");
     }
     
 }
Пример #3
0
        public void Messageboardschedule_CloseSiteInDB_CheckClosedInCSharp()
        {
            Console.WriteLine("TestCodeSignalSendToRecacheSiteListDataViaDotNet");
            // Get the current open and close times for the h2g2 site
            DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
            request.RequestPage("acs?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");

            // Now check to make sure that the XML for the sitelist has not changed
            request.RequestPage("?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");

            // Now set the site to be closed
            Assert.IsTrue(SetSiteEmergencyClosed(true), "Failed to close h2g2");

            // Now check to make sure that the XML for the sitelist has not changed
            request.RequestPage("acs?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");

            // Now check to make sure that the XML for the sitelist has not changed
            request.RequestPage("?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");

            // Now send the recache signal and check to make sure that the times are updated!
            using (FullInputContext inputContext = new FullInputContext(false))
            {
                inputContext.SendSignal("action=recache-site");

                // Now check to make sure that the XML for the sitelist has not changed
                request.RequestPage("acs?skin=purexml");
                Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
                Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "1");

                // Now check to make sure that the XML for the sitelist has not changed
                request.RequestPage("?skin=purexml");
                Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
                Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "1");

                // Now set the site to be open
                Assert.IsTrue(SetSiteEmergencyClosed(false), "Failed to open h2g2");

                // Double check to make sure it's back to normal
                // Now send the recache signal and check to make sure that the times are updated!
                inputContext.SendSignal("action=recache-site");
            }
            // Now check to make sure that the closed value has been put back correctly
            request.RequestPage("acs?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE/SITECLOSED").InnerXml, "0");

            // Now check to make sure that the closed value has been put back correctly
            request.RequestPage("?skin=purexml");
            Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED") != null);
            Assert.AreEqual(request.GetLastResponseAsXML().SelectSingleNode("/H2G2/SITE-CLOSED").InnerXml, "0");
        }
Пример #4
0
 public void TidyUp()
 {
     // Make sure the times get put back correctly
     SetSiteEmergencyClosed(false);
     using (FullInputContext inputContext = new FullInputContext(false))
     {
         inputContext.SendSignal("action=recache-site");
     }
 }
        /*
        /// <summary>
        /// Helper method that signals for a site to be closed/open and then waits for that site to recieve and process the signal
        /// </summary>
        /// <param name="siteClosed">The state that you want tohe site to be in. 1 = closed, 0 = open</param>
        /// <returns>True if the site was updated, false if not</returns>
        private static bool SignalAndWaitforSiteToOpenOrClose(int siteClosed)
        {
            // Make sure the site is open
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserEditor();
            request.UseEditorAuthentication = true;
            if (siteClosed > 0)
            {
                request.RequestPage("messageboardschedule?action=closesite&confirm=1&skin=purexml");
            }
            else
            {
                request.RequestPage("messageboardschedule?action=opensite&confirm=1&skin=purexml");
            }

            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2[SITE-CLOSED='" + siteClosed.ToString() + "']") != null, "The haveyoursay site was not updated correctly! Please check your database!");

            // Now wait untill the .net has been signaled by ripley that we need to recache site data. Emergency closed is in the data!!!
            // Make sure we've got a drop clause after 15 seconds!!!
            int tries = 0;
            bool updated = false;
            Console.Write("Waiting for open/close signal to be processed ");
            while (tries++ <= 20 && !updated)
            {
                //request.RequestPage("acswithoutapi?skin=purexml");
                if (siteClosed > 0)
                {
                    request.RequestPage("messageboardschedule?action=closesite&confirm=1&skin=purexml");
                }
                else
                {
                    request.RequestPage("messageboardschedule?action=opensite&confirm=1&skin=purexml");
                } 
                
                if (request.GetLastResponseAsXML().SelectSingleNode("//SITE/SITECLOSED") != null)
                {
                    updated = request.GetLastResponseAsXML().SelectSingleNode("//SITE/SITECLOSED").InnerXml.CompareTo(siteClosed.ToString()) == 0;

                    if (!updated)
                    {
                        // Goto sleep for 5 secs
                        System.Threading.Thread.Sleep(5000);
                        Console.Write(".");
                    }
                }
            }
            tries *= 5;
            Console.WriteLine(" waited " + tries.ToString() + " seconds.");
            return updated;
        }
         * */
        private bool SetSiteEmergencyClosed(bool setClosed)
        {
            // Set the value in the database
            try
            {
                IInputContext context = DnaMockery.CreateDatabaseInputContext();
                using (IDnaDataReader dataReader = context.CreateDnaDataReader("updatesitetopicsclosed"))
                {
                    dataReader.AddParameter("siteid", 1);
                    dataReader.AddParameter("siteemergencyclosed", setClosed ? 1 : 0);
                    dataReader.Execute();
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
                return false;
            }

            using (FullInputContext inputContext = new FullInputContext(true))
            {
                inputContext.SendSignal("action=recache-site");
            }

            return true;
        }
Пример #6
0
        private static void SignalAndWaitforSiteOptionToBeSet(string siteName, int siteid, string section, string name, string value)
        {
            // Create a context that will provide us with real data reader support
            IInputContext testContext = DnaMockery.CreateDatabaseInputContext();

            // Now create a datareader to set the Generate Hotlist flag
            using (IDnaDataReader reader = testContext.CreateDnaDataReader("setsiteoption"))
            {
                reader.AddParameter("SiteID", siteid);
                reader.AddParameter("Section", section);
                reader.AddParameter("Name", name);
                reader.AddParameter("Value", value);
                reader.Execute();
            }

            using (FullInputContext inputContext = new FullInputContext(""))
            {//send signal
                inputContext.SendSignal("action=recache-site");
            }
        }
 public void TearDown()
 {
     using (FullInputContext inputcontext = new FullInputContext(true))
     {
         using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
         {
             reader.ExecuteDEBUGONLY("delete from GroupMembers where UserId=" + TestUserAccounts.GetNormalUserAccount.UserID);
             reader.ExecuteDEBUGONLY("delete from ModerationClassMembers where UserId=" + TestUserAccounts.GetNormalUserAccount.UserID);
         }
         inputcontext.SendSignal("action=recache-groups&userid=" + TestUserAccounts.GetNormalUserAccount.UserID);
     }
 }