public void Test1CreateForumWithNoCloseDate()
        {
            Console.WriteLine("Before CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate");

            // Create a new comment box with no closing date
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            // Setup the request url
            string uid = Guid.NewGuid().ToString();
            string title = "Testing";
            string hosturl = "http://local.bbc.co.uk/dna/haveyoursay/acs";
            string url = "acs?dnauid=" + uid + "&dnainitialtitle=" + title + "&dnahostpageurl=" + hosturl + "&dnaforumduration=0&skin=purexml";

            // now get the response
            request.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.OuterXml, _schemaUri);
            validator.Validate();
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null,"Comment box tag doers not exist!");
            //Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/ENDDATE") != null,"End date missing when specified!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@UID='" + uid + "']") != null, "Forums uid does not matched the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@HOSTPAGEURL='" + hosturl + "']") != null, "Host url does not match the one used to create!");
            Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS[@CANWRITE='1']") != null, "The forums can write flag should be set 1");

            Console.WriteLine("After CommentForumClosingDateTests - Test1CreateForumWithNoCloseDate");
        }
Example #2
0
        public void repeatCreateForum()
        {
            Console.WriteLine("Before uniqueId - repeatCreateForum");
            
            // test variant data
            string sharedId = "";
            string sharedIdRemembered = "";

            // these will come out of the call to createForum so that they can be used in the checking
            string title1 = "";
            string title2 = "test2";
            string parentUri1 = "";
            string parentUri2 = "url2";

            // working data
            int newSiteCount = 0;
            DnaTestURLRequest theRequest = null;
            XmlDocument xmlOut = null;
            DnaXmlValidator validator = null;
            BBC.Dna.Api.CommentForum returnedForum = null;

            // first time around, expect to be able to create the forum
            testUtils_CommentsAPI.runningForumCount = testUtils_CommentsAPI.countForums(testUtils_CommentsAPI.sitename);

            theRequest = createForum(ref sharedId, ref title1, ref parentUri1);

            newSiteCount = testUtils_CommentsAPI.countForums(testUtils_CommentsAPI.sitename); // there should be 1 more forum

            Assert.IsTrue(newSiteCount == (testUtils_CommentsAPI.runningForumCount + 1));

            sharedIdRemembered = sharedId; // remember it because the next call to createForum may change it.

            testUtils_CommentsAPI.runningForumCount = newSiteCount;

            // second time around, 
            // expect this to fail because the ID is the same
            parentUri2 = parentUri1 + "2";
            theRequest = createForum(ref sharedId, ref title2, ref parentUri2);

            /*
             * this repeatedly times-out
            newSiteCount = testUtils_CommentsAPI.countForums(testUtils_CommentsAPI.sitename); // there should be 1 more forum

            Assert.IsTrue(newSiteCount == testUtils_CommentsAPI.runningForumCount);
            */

            // the response matches the schema
            xmlOut = theRequest.GetLastResponseAsXML(); // 1d. check the result of the creation process is good
            validator = new DnaXmlValidator(xmlOut.InnerXml, testUtils_CommentsAPI._schemaCommentForum);
            validator.Validate();

            // the returned forum should be the one that was initially created
            returnedForum = (BBC.Dna.Api.CommentForum)StringUtils.DeserializeObject(theRequest.GetLastResponseAsString(), typeof(BBC.Dna.Api.CommentForum));
            Assert.IsTrue(returnedForum.Id == sharedIdRemembered, "The new forum's ID has chagned from " +sharedIdRemembered+" to " +returnedForum.Id);
            Assert.IsTrue(returnedForum.Title == title2, "The new forum's Title has cahgned from " +title1+ " to " +returnedForum.Title);
            Assert.IsTrue(returnedForum.ParentUri == parentUri2, "The new forum's ParentURI has changed from " +parentUri1+ " to " +returnedForum.ParentUri);
            Assert.IsTrue(returnedForum.commentList.TotalCount == 0, "The new forum's should have an empty commentList, it is not empty");
            
            Console.WriteLine("After uniqueId - repeatCreateForum");
        }
        public static int runningForumCount = 0; // used to see our starting count, before we start adding forums.

        /// <summary>
        /// Simply count the number of commentsForums that have been created so far on this site
        /// </summary>
        /// <param name="SiteName">the name of the sute to query</param>
        /// <returns>teh count</returns>
        public static int countForums(string SiteName)
        {
            string _server = DnaTestURLRequest.CurrentServer;

            DnaTestURLRequest request = new DnaTestURLRequest(SiteName);

            request.SetCurrentUserNormal();

            // Setup the request url
            string url = "http://" + _server + "/dna/api/comments/CommentsService.svc/v1/site/" + SiteName + "/";

            // now get the response - no POST data, nor any clue about the input mime-type
            request.RequestPageWithFullURL(url, "", "");

            Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.OK);

            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList);
            validator.Validate();

            BBC.Dna.Api.CommentForumList returnedList = (BBC.Dna.Api.CommentForumList)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.CommentForumList));
            Assert.IsTrue(returnedList != null);

            return returnedList.TotalCount;
        }
        public void DuplicatePostParams()
        {
            Console.WriteLine("DuplicatePostParams");
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");

            Queue<KeyValuePair<string, string>> postparams = new Queue<KeyValuePair<string, string> >();
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "1,1"));
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "2,2"));
            postparams.Enqueue(new KeyValuePair<string,string>("s_param", "3,3"));
            request.RequestPage("acs?skin=purexml", postparams);

            string paramvalue = "1,1,2,2,3,3";
            XmlDocument doc = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd");
            validator.Validate();

            validator = new DnaXmlValidator(doc.SelectSingleNode(@"H2G2/PARAMS").OuterXml, "Params.xsd");
            validator.Validate();

            XmlNodeList nodes = doc.SelectNodes(@"H2G2/PARAMS/PARAM");
            foreach (XmlNode node in nodes)
            {
                Assert.AreEqual(paramvalue, node.SelectSingleNode("VALUE").InnerText);
            }
        }
Example #5
0
        public void inXMLoutXML()
        {
            Console.WriteLine("Before formatParamTests - inXMLoutXML");

            // test variants
            string formatParam = "XML";
            HttpStatusCode expectedCode = HttpStatusCode.OK;

            // working data
            int inputRating = 0;
            string inputText = "";
            DnaTestURLRequest myRequest = null;

            // run test
            myRequest = do_it(formatParam, ref inputText, ref inputRating);

            Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == expectedCode,
                "Expecting " + expectedCode + " as response, got " + myRequest.CurrentWebResponse.StatusCode + "\n" + myRequest.CurrentWebResponse.StatusDescription
                );

            XmlDocument xml = myRequest.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaRatingForum);
            validator.Validate();

            RatingInfo returnedRating = (RatingInfo)StringUtils.DeserializeObject(myRequest.GetLastResponseAsString(), typeof(RatingInfo));

            Assert.IsTrue(returnedRating.text == inputText);
            Assert.IsTrue(returnedRating.rating == inputRating);
            Assert.IsNotNull(returnedRating.User);
            Assert.IsTrue(returnedRating.User.UserId == myRequest.CurrentUserID);

            Console.WriteLine("After formatParamTests - inXMLoutXML");
        }
        public void GuideMLTranslatorTests_PlainTextToGuideML_HttpToClickableLink_Basic()
        {
            GuideMLTranslator guideMLTranslator = new GuideMLTranslator(); 
            string guideML;

            guideML = guideMLTranslator.PlainTextToGuideML("http://www.bbc.co.uk/");
            DnaXmlValidator validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY><LINK HREF=\"http://www.bbc.co.uk/\">http://www.bbc.co.uk/</LINK></BODY></GUIDE>", guideML);

            guideML = guideMLTranslator.PlainTextToGuideML("Check out some nonsense here: http://www.bbc.co.uk/dna/mb606/A123");
            validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY>Check out some nonsense here: <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/A123\">http://www.bbc.co.uk/dna/mb606/A123</LINK></BODY></GUIDE>", guideML);

            guideML = guideMLTranslator.PlainTextToGuideML("http1 = http://www.bbc.co.uk/dna/mb606/A123 http2 http://www.bbc.co.uk/dna/mb606/A456");
            validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY>http1 = <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/A123\">http://www.bbc.co.uk/dna/mb606/A123</LINK> http2 <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/A456\">http://www.bbc.co.uk/dna/mb606/A456</LINK></BODY></GUIDE>", guideML);

            guideML = guideMLTranslator.PlainTextToGuideML("http1 = http://www.bbc.co.uk/dna/mb606/A123 http2 http://www.bbc.co.uk/dna/mb606/A456 http 3 = http://www.bbc.co.uk/dna/mb606/789 more text");
            validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY>http1 = <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/A123\">http://www.bbc.co.uk/dna/mb606/A123</LINK> http2 <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/A456\">http://www.bbc.co.uk/dna/mb606/A456</LINK> http 3 = <LINK HREF=\"http://www.bbc.co.uk/dna/mb606/789\">http://www.bbc.co.uk/dna/mb606/789</LINK> more text</BODY></GUIDE>", guideML);

            guideML = guideMLTranslator.PlainTextToGuideML("http://www.bbc.co.uk/dna/mb606 is a good site.");
            validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY><LINK HREF=\"http://www.bbc.co.uk/dna/mb606\">http://www.bbc.co.uk/dna/mb606</LINK> is a good site.</BODY></GUIDE>", guideML);

            guideML = guideMLTranslator.PlainTextToGuideML("Some text?");
            validator = new DnaXmlValidator(guideML, _schemaUri);
            validator.Validate();
            Assert.AreEqual("<GUIDE><BODY>Some text?</BODY></GUIDE>", guideML);
        }
Example #7
0
 public void Category_SerializedXML_PassesSchemaValidation()
 {
     var hierarchyDetails = CreateTestCategory();
     var objXml = StringUtils.SerializeToXmlUsingXmlSerialiser(hierarchyDetails);
     var validator = new DnaXmlValidator(objXml, "Category.xsd");
     validator.Validate();
 }
        public void UseRedirectParameterTest()
        {

            Console.WriteLine("Before UseRedirectParameterTest");
            Mockery mock = new Mockery();
            IUser viewingUser = mock.NewMock<IUser>();
            Stub.On(viewingUser).GetProperty("UserLoggedIn").Will(Return.Value(true));
            Stub.On(viewingUser).GetProperty("Email").Will(Return.Value("*****@*****.**"));
            Stub.On(viewingUser).GetProperty("IsEditor").Will(Return.Value(false));
            Stub.On(viewingUser).GetProperty("IsSuperUser").Will(Return.Value(false));
            Stub.On(viewingUser).GetProperty("IsBanned").Will(Return.Value(false));

            ISite site = mock.NewMock<ISite>();
            Stub.On(site).GetProperty("IsEmergencyClosed").Will(Return.Value(false));
            Stub.On(site).Method("IsSiteScheduledClosed").Will(Return.Value(false));
            Stub.On(site).GetProperty("SiteID").Will(Return.Value(1));

            IInputContext context = DnaMockery.CreateDatabaseInputContext();
            Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(viewingUser));
            Stub.On(context).GetProperty("CurrentSite").Will(Return.Value(site));

            DnaMockery.MockTryGetParamString(context,"dnauid", "this is some unique id blah de blah blah2");
            //Stub.On(context).Method("TryGetParamString").WithAnyArguments().Will(new TryGetParamStringAction("dnauid","this is some unique id blah de blah blah2"));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnauid"), Is.Anything).Will(Return.Value(true));

            DnaMockery.MockTryGetParamString(context,"dnahostpageurl", "http://www.bbc.co.uk/dna/something");
            //Stub.On(context).Method("TryGetParamString").With("dnahostpageurl").Will(new TryGetParamStringAction("dnahostpageurl","http://www.bbc.co.uk/dna/something"));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnahostpageurl"), Is.Anything).Will(Return.Value(true));

            DnaMockery.MockTryGetParamString(context,"dnainitialtitle", "newtitle");
            //Stub.On(context).Method("TryGetParamString").With("dnainitialtitle").Will(new TryGetParamStringAction("dnainitialtitle", "newtitle"));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnainitialtitle"), Is.Anything).Will(Return.Value(true));

            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnaerrortype"),Is.Anything).Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("moduserid"), Is.Anything).Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnainitialmodstatus"), Is.Anything).Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnaforumclosedate"), Is.Anything).Will(Return.Value(false));
            Stub.On(context).Method("DoesParamExist").With(Is.EqualTo("dnaforumduration"), Is.Anything).Will(Return.Value(false));

            Stub.On(context).Method("GetParamIntOrZero").With(Is.EqualTo("dnafrom"), Is.Anything).Will(Return.Value(0));
            Stub.On(context).Method("GetParamIntOrZero").With(Is.EqualTo("dnato"), Is.Anything).Will(Return.Value(0));
            Stub.On(context).Method("GetParamIntOrZero").With(Is.EqualTo("dnashow"), Is.Anything).Will(Return.Value(0));

            
            
            Stub.On(context).Method("GetSiteOptionValueInt").With("CommentForum","DefaultShow").Will(Return.Value(20));
            //inputContext.InitialiseFromFile(@"../../testredirectparams.txt", @"../../userdave.txt");

            CommentBoxForum forum = new CommentBoxForum(context);
            forum.ProcessRequest();


            string forumXml = forum.RootElement.InnerXml;
            DnaXmlValidator validator = new DnaXmlValidator(forumXml, "CommentBox.xsd");
            validator.Validate();
            Console.WriteLine("After UseRedirectParameterTest");
        }
Example #9
0
        public void ArticleInfoXmlTest()
        {
            ArticleInfo target = ArticleInfoTest.CreateArticleInfo();

            XmlDocument xml = Serializer.SerializeToXml(target);
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, "articleinfo.xsd");
            validator.Validate();

            //string json = Serializer.SerializeToJson(target);
        }
Example #10
0
        public void inXMLoutXML()
        {
            Console.WriteLine("Before formatParamTests - inXMLoutXML");

           // test variant data
            string mimeType = "text/xml";
            string formatParam = "XML";

            HttpStatusCode expectedResponseCode = HttpStatusCode.OK;

            // working data
            string id = "";
            string title = "";
            string parentUri = "";

            // make the post as XML data
            string postData = testUtils_ratingsAPI.makeCreatePostXml_minimal(ref id, ref title, ref parentUri);
            
            string url = testUtils_ratingsAPI.makeCreateForumUrl() + "?format=" + formatParam;

            DnaTestURLRequest request = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);

            request.SetCurrentUserEditor();

            try
            {
                request.RequestPageWithFullURL(url, postData, mimeType);
            }
            catch
            {
                string resp = request.GetLastResponseAsString(); // usefull when debugging
                if (expectedResponseCode == HttpStatusCode.OK)
                    Assert.Fail("Fell over: " + resp); 
            }

            Assert.IsTrue(
                request.CurrentWebResponse.StatusCode == expectedResponseCode, 
                "HTTP repsonse. Expected:" + expectedResponseCode + " actually got " + request.CurrentWebResponse.StatusCode
                );

            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaRatingForum);
            validator.Validate();

            BBC.Dna.Api.RatingForum returnedForum = 
                (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum)
                );

            Assert.IsTrue(returnedForum.Id == id);
            Assert.IsTrue(returnedForum.Title == title);
            Assert.IsTrue(returnedForum.ParentUri == parentUri);
            Assert.IsTrue(returnedForum.ratingsList.TotalCount == 0);

            Console.WriteLine("After formatParamTests - inXMLoutXML");
        } // ends inXMLoutXML
Example #11
0
        public void Test1UserListClassTest_CreateNewUsersList()
        {
            UserList userList = new UserList(_InputContext);
            Assert.IsTrue(userList.CreateNewUsersList(10, "YEAR", 10, 0, false, "", _InputContext.CurrentSite.SiteID, 0), "Failed creation of list");

            XmlElement xml = userList.RootElement;
            
            Assert.IsTrue(xml.SelectSingleNode("USER-LIST") != null, "The xml is not generated correctly!!!");
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }
Example #12
0
 public void SiteOptions_ValidateSiteOptionsXMLFromBBCDNA_ExpectValid()
 {
     // Get the XML from the c#
     DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
     request.RequestPage("Status-n?skin=purexml");
     XmlDocument xDoc = request.GetLastResponseAsXML();
     XmlElement siteoptions = (XmlElement)xDoc.SelectSingleNode("/H2G2/SITE/SITEOPTIONS");
     Assert.IsNotNull(siteoptions, "Failed to get the site options from the XML");
     DnaXmlValidator validator = new DnaXmlValidator(siteoptions, "SiteOptions.xsd");
     validator.Validate();
 }
Example #13
0
		public void TestAcsRequest()
		{
			DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
			request.RequestPage(@"acs?dnatitle=New+Comment+Box2&dnaurl=http://local.bbc.co.uk:8000/testpage.shtml&dnauid=552F1F05-74AD-410b-880C-F37B83D8B69A&skin=purexml");
			XmlDocument doc = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2CommentBoxFlat.xsd");
            validator.Validate();
			Assert.IsTrue(doc.SelectSingleNode("/H2G2/SERVERNAME") != null, "No SERVERNAME element found");
			Assert.IsTrue(doc.SelectSingleNode("/H2G2/TIMEFORPAGE") != null, "No TIMEFORPAGE element found");
			Assert.IsTrue(doc.SelectSingleNode("/H2G2/USERAGENT") != null, "No USERAGENT element found");
		}
Example #14
0
        public void AddResults()
        {
            _pollResults.Add(Poll.UserStatus.USERSTATUS_LOGGEDIN, 1, "blah", "1");
            _pollResults.Add(Poll.UserStatus.USERSTATUS_LOGGEDIN, 2, "blah2", "2");
            _pollResults.Add(Poll.UserStatus.USERSTATUS_HIDDEN, 1, "hidden", "0");
            XmlElement xml = _pollResults.GetXml();

            DnaXmlValidator validator = new DnaXmlValidator(xml, "OptionList.xsd");
            validator.Validate();

            Assert.IsTrue(xml.OuterXml.Equals("<OPTION-LIST><USERSTATUS TYPE=\"1\"><OPTION INDEX=\"blah\" COUNT=\"1\" /><OPTION INDEX=\"blah2\" COUNT=\"2\" /></USERSTATUS><USERSTATUS TYPE=\"2\"><OPTION INDEX=\"hidden\" COUNT=\"0\" /></USERSTATUS></OPTION-LIST>"), "AddThreeResults: Xml is not what we were expecting"); 
        }
        public void TestThreadSearchPhraseNoPhrase()
        {
            Console.WriteLine("ThreadSearchPhraseTest");
            _request.RequestPage("tsp?skin=purexml&clear_templates=1");
            Console.WriteLine("ThreadSearchPhraseTest");

            XmlDocument xml = _request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode(@"H2G2/THREADSEARCHPHRASE/PHRASES[@COUNT=0]") != null, "Incorrect Phrase count. Expecting 0");

            DnaXmlValidator validator = new DnaXmlValidator(xml.SelectSingleNode("H2G2/THREADSEARCHPHRASE").OuterXml, "threadsearchphrase.xsd");
            validator.Validate();
        }
Example #16
0
        public void inXMLoutXML()
        {
            Console.WriteLine("Before formatParam - inXMLoutXML");

           // test variant data
            string formatParam = "XML";
            HttpStatusCode expectedResponseCode = HttpStatusCode.OK;

            // consistent input data
            string id = "";
            string title = "";
            string parentUri = "";
            string mimeType = "text/xml";
            string filename = "";
            string postXML = testUtils_CommentsAPI.makePostXml(ref id, ref title, ref parentUri);

            // working data
            int newSiteCount = 0;
            DnaTestURLRequest request;
            XmlDocument xml;
            DnaXmlValidator validator;
            BBC.Dna.Api.CommentForum returnedForum;

            //go
            request = makeRequest(formatParam, filename, postXML, mimeType);

            Assert.IsTrue(
                request.CurrentWebResponse.StatusCode == expectedResponseCode, 
                "HTTP repsonse. Expected:" + expectedResponseCode + " actually got " + request.CurrentWebResponse.StatusCode
                );

            newSiteCount = testUtils_CommentsAPI.countForums(testUtils_CommentsAPI.sitename);

            Assert.IsTrue(newSiteCount == (testUtils_CommentsAPI.runningForumCount + 1));

            testUtils_CommentsAPI.runningForumCount = newSiteCount;

            xml = request.GetLastResponseAsXML();
            validator = new DnaXmlValidator(xml.InnerXml, testUtils_CommentsAPI._schemaCommentForum);
            validator.Validate();

            returnedForum = 
                (BBC.Dna.Api.CommentForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.CommentForum)
                );

            Assert.IsTrue(returnedForum.Id == id);
            Assert.IsTrue(returnedForum.Title == title);
            Assert.IsTrue(returnedForum.ParentUri == parentUri);
            Assert.IsTrue(returnedForum.commentList.TotalCount == 0);


            Console.WriteLine("After formatParam - inXMLoutXML");
        } // ends inXMLoutXML
        public void Test02ArticleSearchWithinDateRangeTest()
        {
            Console.WriteLine("Test02ArticleSearchDateRangeTest");
            _request.RequestAspxPage("ArticleSearchPage.aspx", @"skip=0&show=10&contenttype=-1&datesearchtype=1&skin=purexml&startday=1&startmonth=1&startyear=2006&&endday=1&endmonth=1&endyear=2007");
            Console.WriteLine("After Test02ArticleSearchDateRangeTest");

            XmlDocument xml = _request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("H2G2/ARTICLESEARCH[@DATESEARCHTYPE=1]") != null, "The within date range article search page has not been generated correctly!!!");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }
        public void Test1UserComplaintPage()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();
            request.UseEditorAuthentication = false;
            request.RequestPage("UserComplaintPage?skin=purexml" + "&postid=" + Convert.ToString(_postId) );

            XmlDocument doc = request.GetLastResponseAsXML();

            //Check XML against Schema.
            DnaXmlValidator validator = new DnaXmlValidator(doc.InnerXml, "H2G2UserComplaintFlat.xsd");
            validator.Validate();
        }
Example #19
0
 public void Test2TestSiteID()
 {
     Console.WriteLine("Test2TestSiteID");
     Assert.AreEqual(_testSite.SiteID, 1);
     SiteXmlBuilder siteXml = new SiteXmlBuilder(_inputcontext);
     XmlNode testnode = siteXml.GenerateXml(null, _testSite);
     DnaXmlValidator validator = new DnaXmlValidator(testnode.OuterXml, _schemaUri);
     validator.Validate();
     if (testnode != null)
     {
         Assert.AreEqual(testnode.Attributes["ID"].InnerText, "1", "Site ID Attribute Xml incorrect");
     }
 }
Example #20
0
 public void Test3TestSiteName()
 {
     Console.WriteLine("Test3TestSiteName");
     Assert.AreEqual(_testSite.SiteName, "h2g2");
     SiteXmlBuilder siteXml = new SiteXmlBuilder(_inputcontext);
     XmlNode testnode = siteXml.GenerateXml(null, _testSite);
     DnaXmlValidator validator = new DnaXmlValidator(testnode.OuterXml, _schemaUri);
     validator.Validate();
     if (testnode != null)
     {
         Assert.AreEqual(testnode.SelectSingleNode("NAME").InnerText, "h2g2", "Site Name Xml incorrect");
     }
 }
        public void TestModeratorManagementPageXml()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("moderation");
            request.SetCurrentUserSuperUser();
            request.UseEditorAuthentication = true;
            request.RequestPage(@"ModeratorManagement?skin=purexml");

            XmlDocument xml = request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("H2G2") != null, "The page does not exist!!!");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, "H2G2ModeratorManagementPage.xsd");
            validator.Validate();
        }
Example #22
0
		public void TestSkinParams()
		{
            Console.WriteLine("TestSkinParams");
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                inputcontext.SetCurrentSite("h2g2");
                inputcontext.InitDefaultUser();

                inputcontext.AddParam("s_abcde", "xyzzy");
                inputcontext.AddParam("notaskinparam", "abcde");
                inputcontext.AddParam("s_xxxxx", "plugh");
                inputcontext.AddParam("ss_not", "doesn't matter");

                SkinParams sparams = new SkinParams(inputcontext);
                sparams.ProcessRequest();
                DnaXmlValidator validator = new DnaXmlValidator(sparams.RootElement.InnerXml, _schemaUri);
                validator.Validate();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(sparams.RootElement.OuterXml);

                XmlNode node = doc.SelectSingleNode("/DNAROOT/PARAMS");
                Assert.IsNotNull(node, "No PARAMS element found");
                XmlNodeList nodes = doc.SelectNodes("/DNAROOT/PARAMS/PARAM");

                Assert.IsNotNull(nodes, "Unable to find /DNAROOT/PARAMS/PARAM");

                Assert.IsTrue(nodes.Count == 2, string.Format("Expecting 2 s_ params in query, found {0}", nodes.Count));

                foreach (XmlNode subnode in nodes)
                {
                    XmlNode name = subnode.SelectSingleNode("NAME");
                    XmlNode value = subnode.SelectSingleNode("VALUE");
                    Assert.IsNotNull(name, "NAME missing from PARAM object");
                    Assert.IsNotNull(value, "VALUE missing from PARAM object");
                    if (name.InnerText == "s_abcde")
                    {
                        Assert.AreEqual(value.InnerText, "xyzzy", "s_abcde value doesn't match");
                    }
                    else if (name.InnerText == "s_xxxxx")
                    {
                        Assert.AreEqual(value.InnerText, "plugh", "Value of s_xxxxx doesn't match");
                    }
                    else
                    {
                        Assert.Fail(string.Format("Unexpected param found: {0}", name.InnerText));
                    }
                }
            }
		}
Example #23
0
        public void BlogSummaryPageExists()
        {
            DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
            request.SetCurrentUserNormal();

            string url = "BlogSummary?skin=purexml&dna_list_ns=1";

            request.RequestPage(url);

            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }
Example #24
0
        public void GetForumThreadsXml_ReadOnly_ReturnsValidXml()
        {
            Console.WriteLine("Before GetForumXml_ReadOnly_ReturnsValidXml");

            DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
            request.SetCurrentUserNormal();
            string url = String.Format("http://" + _server + "/dna/api/forums/ForumsService.svc/V1/site/{0}/forums/{1}/threads/{2}?format=xml", _sitename, 150, 33);
            // now get the response
            request.RequestPageWithFullURL(url, null, "text/xml");
            // Check to make sure that the page returned with the correct information
            XmlDocument xml = request.GetLastResponseAsXML();
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml.Replace("xmlns=\"http://schemas.datacontract.org/2004/07/BBC.Dna.Objects\"","") , _schemaForumThreads);
            validator.Validate();

            Console.WriteLine("After GetForumXml_ReadOnly_ReturnsValidXml");
        }
Example #25
0
        public void Test03CheckOutputFormatMoreCommentsPageTest()
        {
            Console.WriteLine("Before Test03CheckOutputFormatMoreCommentsPageTest");
            _request.RequestPage("MC6?skin=purexml");
            Console.WriteLine("After Test03CheckOutputFormatMoreCommentsPageTest");

            XmlDocument xml = _request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORECOMMENTS/COMMENTS-LIST") != null, "The comments list page has not been generated!!!");

            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORECOMMENTS/COMMENTS-LIST/@SKIP") != null, "The comment list page has not been generated correctly - SKIP!!!");
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORECOMMENTS/COMMENTS-LIST/@SHOW") != null, "The comment list page has not been generated correctly - SHOW!!!");
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORECOMMENTS[@USERID='6']") != null, "The comment list page has not been generated correctly - USERID!!!");
           
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }
Example #26
0
        public void Test02ValidateUserPage()
        {
            Console.WriteLine("Before Test02ValidateUserPage");

            //request the page
            _request.RequestPage("U" + _request.CurrentUserID + "&skin=purexml");

            // now get the response
            XmlDocument xml = _request.GetLastResponseAsXML();

            // Check to make sure that the page returned with the correct information
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Console.WriteLine("After Test02ValidateUserPage");
        }
Example #27
0
        public void Test02ValidateMoreJournalPage()
        {
            Console.WriteLine("Before Test02ValidateMoreJournalPage");

            //request the page
            _request.RequestPage("MJ1090501859&journal=7618990?skin=purexml");

            // now get the response
            XmlDocument xml = _request.GetLastResponseAsXML();

            // Check to make sure that the page returned with the correct information
            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Console.WriteLine("After Test02ValidateMoreJournalPage");
        }
Example #28
0
        public void Test01GetDefaultUserList()
        {
            Console.WriteLine("Before UserPageTests - Test01GetDefaultUserList");

            //request the page
            _request.RequestPage("NewUsers?skin=purexml");

            // now get the response
            XmlDocument xml = _request.GetLastResponseAsXML();

            // Check to make sure that the page returned with the correct information
            XmlNode xmlSub = xml.SelectSingleNode("/H2G2/NEWUSERS-LISTING");
            Assert.IsTrue(xmlSub != null, "User list does not exist!");
            DnaXmlValidator validator = new DnaXmlValidator(xmlSub.OuterXml, _schemaUri);
            validator.Validate();
            Console.WriteLine("After Test01GetDefaultUserList");
        }
Example #29
0
        public void Test02GetUserListWithoutFilter()
        {
            Console.WriteLine("Before Test02GetUserListWithoutFilter");

            //request the page
            _request.RequestPage("NewUsers?TimeUnits=10&UnitType=month&Filter=off&thissite=1&skin=purexml");

            // now get the response
            XmlDocument xml = _request.GetLastResponseAsXML();

            // Check to make sure that the page returned with the correct information
            XmlNode xmlSub = xml.SelectSingleNode("/H2G2/NEWUSERS-LISTING");
            Assert.IsTrue(xmlSub != null, "User list does not exist!");
            DnaXmlValidator validator = new DnaXmlValidator(xmlSub.OuterXml, _schemaUri);
            validator.Validate();
            Console.WriteLine("After Test02GetUserListWithoutFilter");
        }
        public void Test01CreateMoreSubscribingUsersPageTest()
        {
            _request.RequestPage("MLS6?skin=purexml");

            XmlDocument xml = _request.GetLastResponseAsXML();
            Assert.IsTrue(xml.SelectSingleNode("H2G2") != null, "The page does not exist!!!");

            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORELINKSUBSCRIPTIONS/USERSUBSCRIPTIONLINKS-LIST") != null, "The UserSubscriptionLinks-List was not generated");
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORELINKSUBSCRIPTIONS/USERSUBSCRIPTIONLINKS-LIST/@SKIP") != null, "The UserSubscriptionLinks-List skip parameter was not generated");
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORELINKSUBSCRIPTIONS/USERSUBSCRIPTIONLINKS-LIST/@SHOW") != null, "The UserSubscriptionLinks-List show parameter was not generated");

            //Check the User XML for user 6.
            Assert.IsTrue(xml.SelectSingleNode("H2G2/MORELINKSUBSCRIPTIONS/USERSUBSCRIPTIONLINKS-LIST/USER[USERID='6']") != null, "The UserSubscriptionLinks-List user block was not generated correctly.");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }