本文整理汇总了C#中Tests.DnaXmlValidator类的典型用法代码示例。如果您正苦于以下问题:C# DnaXmlValidator类的具体用法?C# DnaXmlValidator怎么用?C# DnaXmlValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DnaXmlValidator类属于Tests命名空间,在下文中一共展示了DnaXmlValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test1CreateForumWithNoCloseDate
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");
}
示例2: repeatCreateForum
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");
}
示例3: countForums
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;
}
示例4: DuplicatePostParams
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);
}
}
示例5: inXMLoutXML
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");
}
示例6: GuideMLTranslatorTests_PlainTextToGuideML_HttpToClickableLink_Basic
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);
}
示例7: Category_SerializedXML_PassesSchemaValidation
public void Category_SerializedXML_PassesSchemaValidation()
{
var hierarchyDetails = CreateTestCategory();
var objXml = StringUtils.SerializeToXmlUsingXmlSerialiser(hierarchyDetails);
var validator = new DnaXmlValidator(objXml, "Category.xsd");
validator.Validate();
}
示例8: UseRedirectParameterTest
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("[email protected]"));
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");
}
示例9: ArticleInfoXmlTest
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);
}
示例10: Test1UserListClassTest_CreateNewUsersList
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();
}
示例11: SiteOptions_ValidateSiteOptionsXMLFromBBCDNA_ExpectValid
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();
}
示例12: TestAcsRequest
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");
}
示例13: AddResults
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");
}
示例14: TestThreadSearchPhraseNoPhrase
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();
}
示例15: inXMLoutXML
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