本文整理汇总了C#中Tests.DnaTestURLRequest.GetLastResponseAsString方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.GetLastResponseAsString方法的具体用法?C# DnaTestURLRequest.GetLastResponseAsString怎么用?C# DnaTestURLRequest.GetLastResponseAsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.GetLastResponseAsString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: inXMLoutXML
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
示例2: 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;
}
示例3: Test02RequestHierarchyPageWithSiteID
public void Test02RequestHierarchyPageWithSiteID()
{
Console.WriteLine("Test02RequestHierarchyPageWithSiteID");
XmlDocument xmldoc = new XmlDocument();
DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
try
{
request.RequestAspxPage("HierarchyPage.aspx", "siteid=16&skin=purexml");
xmldoc.LoadXml(request.GetLastResponseAsString());
}
catch (Exception e)
{
System.Console.Write(e.Message + request.GetLastResponseAsString());
//Assert.Fail(e.Message + _asphost.ResponseString);
}
Assert.IsNotNull(xmldoc.SelectSingleNode("//HIERARCHYNODES"), "Expected a HIERARCHYNODES XML Tag!!!");
Assert.AreEqual("16", xmldoc.SelectSingleNode("//HIERARCHYNODES").Attributes["SITEID"].Value, "Incorrect site id in XML");
}
示例4: TestXSLTCaching
public void TestXSLTCaching()
{
Console.WriteLine("Before TestXSLTCaching");
// First log the user into the system.
DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
request.SetCurrentUserEditor();
// Now create the test skin to use
StreamWriter test1file = new StreamWriter(_testXSLTFilename);
test1file.Write(CreateXSLTFile("XSLT caching test 1"));
test1file.Close();
// Now call the acs page with the clear templates flag and
// check to make sure that it returns the text we supplied in the new xslt file.
request.RequestPage("acs?d_skinfile=" + _testXSLTFilename + "&clear_templates=1");
Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 1"));
// Now update the file so that it says something different.
StreamWriter test2file = new StreamWriter(_testXSLTFilename);
test2file.Flush();
test2file.Write(CreateXSLTFile("XSLT caching test 2"));
test2file.Close();
// Now call the same page. We should still have the old transform in cache, so the text should still reflect what was in the old file!
request.RequestPage("acs?d_skinfile=" + _testXSLTFilename);
Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 1"));
// Now call the acs page and flush the cache. We should now see that it is using the new file and not the old!
request.RequestPage("acs?d_skinfile=" + _testXSLTFilename + "&clear_templates=1");
Assert.IsFalse(request.GetLastResponseAsString().Contains("XSLT caching test 1"));
Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 2"));
// Now delete the file totally! Check to make sure we still have the cached version!
File.Delete(_testXSLTFilename);
request.RequestPage("acs?d_skinfile=" + _testXSLTFilename);
Assert.IsFalse(request.GetLastResponseAsString().Contains("XSLT caching test 1"));
Assert.IsTrue(request.GetLastResponseAsString().Contains("XSLT caching test 2"));
Console.WriteLine("After TestXSLTCaching");
}
示例5: CommentForumCreateHelper
public CommentForum CommentForumCreateHelper()
{
string nameSpace = "Tests";
string id = Guid.NewGuid().ToString();
ModerationStatus.ForumStatus moderationStatus = ModerationStatus.ForumStatus.Reactive;
DateTime closingDate = DateTime.MinValue;
Console.WriteLine("Before CreateCommentForum");
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserEditor();
string title = "Functiontest Title";
string parentUri = "http://www.bbc.co.uk/dna/h2g2/";
string commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
"<id>{0}</id>" +
"<namespace>{3}</namespace>" +
"<title>{1}</title>" +
"<parentUri>{2}</parentUri>" +
"<closeDate>{4}</closeDate>" +
"<moderationServiceGroup>{5}</moderationServiceGroup>" +
"</commentForum>", id, title, parentUri, nameSpace,
closingDate.ToString("yyyy-MM-dd"), moderationStatus);
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
_sitename);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
// Check to make sure that the page returned with the correct information
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
var returnedForum =
(CommentForum) StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForum));
Assert.IsTrue(returnedForum.Id == id);
Assert.IsTrue(returnedForum.ParentUri == parentUri);
Assert.IsTrue(returnedForum.Title == title);
Assert.IsTrue(returnedForum.ModerationServiceGroup == moderationStatus);
return returnedForum;
}
示例6: onlyOnce
public void onlyOnce()
{
Console.WriteLine("Before duplicationTests - onlyOnce");
DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
// Make the forum into which to put ratings
string testForumId = testUtils_ratingsAPI.makeTestForum();
myRequest.SetCurrentUserNormal();
// make a rating for the first time
myRequest = tryIt(testForumId, myRequest);
Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.OK,
"Failed to make the test rating. Expecting " + HttpStatusCode.OK +
" as response, got " + myRequest.CurrentWebResponse.StatusCode + "\n" +
myRequest.CurrentWebResponse.StatusDescription
);
// try and make a second one as the same person
myRequest = tryIt(testForumId, myRequest);
Assert.IsTrue(myRequest.CurrentWebResponse.StatusCode == HttpStatusCode.BadRequest,
"Error making second attempt. Expecting " + HttpStatusCode.BadRequest +
" as response, got " + myRequest.CurrentWebResponse.StatusCode + "\n" +
myRequest.CurrentWebResponse.StatusDescription
);
XmlDocument xml = myRequest.GetLastResponseAsXML();
DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, testUtils_ratingsAPI._schemaError);
validator.Validate();
string resStr = myRequest.GetLastResponseAsString();
Assert.IsTrue(Regex.Match(resStr, "code\\>MultipleRatingByUser<").Success == true);
Assert.IsTrue(Regex.Match(resStr, "already").Success == true);
Console.WriteLine("After duplicationTests - onlyOnce");
}
示例7: FrontPageRedirector_CustomSkin_RedirectsToCPlusHomeWithSkinInTact
public void FrontPageRedirector_CustomSkin_RedirectsToCPlusHomeWithSkinInTact()
{
try
{
SetSiteOptions("");
var request = new DnaTestURLRequest("h2g2");
request.SetCurrentUserNormal();
request.RequestPage("classic/", null);
var lastRequest = request.GetLastResponseAsString();
Assert.IsTrue(lastRequest.IndexOf("%2fdna%2fh2g2%2fclassic%2fhome") > 0);
}
finally
{
UnSetSiteOptions();
}
}
示例8: FrontPageRedirector_NoSiteOption_RedirectsToCPlusHome
public void FrontPageRedirector_NoSiteOption_RedirectsToCPlusHome()
{
try
{
SetSiteOptions("");
var request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserNormal();
request.RequestPage("/", null);
var lastRequest = request.GetLastResponseAsString();
Assert.IsTrue(lastRequest.IndexOf("%2fdna%2fmbiplayer%2fhome") > 0);
}
finally
{
UnSetSiteOptions();
}
}
示例9: GetReviewForumXML
public void GetReviewForumXML()
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
string url = String.Empty;
BBC.Dna.Api.RatingForum ratingForum = CreateRatingForum();
// Setup the request url
url = String.Format("http://" + _server + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, ratingForum.Id);
// now get the response
request.RequestPageWithFullURL(url, "", "text/xml");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaRatingForum);
validator.Validate();
BBC.Dna.Api.RatingForum returnedForum = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
}
示例10: CreateTestForumAndComment
public void CreateTestForumAndComment(ref CommentForum commentForum, ref CommentInfo returnedComment)
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
//create the forum
if (string.IsNullOrEmpty(commentForum.Id))
{
commentForum = commentsHelper.CommentForumCreate("tests", Guid.NewGuid().ToString());
}
string text = "Functiontest Title" + Guid.NewGuid().ToString();
string commentForumXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
"<text>{0}</text>" +
"</comment>", text);
// Setup the request url
string url = String.Format(_secureserver + "dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/", _sitename, commentForum.Id);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
//check the TextAsHtml element
//string textAsHtml = xml.DocumentElement.ChildNodes[2].InnerXml;
//Assert.IsTrue(textAsHtml == "<div class=\"dna-comment text\" xmlns=\"\">" + text + "</div>");
returnedComment = (CommentInfo)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentInfo));
Assert.IsTrue(returnedComment.text == text);
Assert.IsNotNull(returnedComment.User);
Assert.IsTrue(returnedComment.User.UserId == request.CurrentUserID);
DateTime created = DateTime.Parse(returnedComment.Created.At);
DateTime createdTest = BBC.Dna.Utils.TimeZoneInfo.GetTimeZoneInfo().ConvertUtcToTimeZone(DateTime.Now.AddMinutes(5));
Assert.IsTrue(created < createdTest);//should be less than 5mins
Assert.IsTrue(!String.IsNullOrEmpty(returnedComment.Created.Ago));
}
示例11: GetCommentForumsBySitenameAndPrefixXML_WithSorting_ByCreated
public void GetCommentForumsBySitenameAndPrefixXML_WithSorting_ByCreated()
{
Console.WriteLine("Before GetCommentForumsBySitenameXML");
//create 3 forums with a prefix and one without
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserEditor();
string prefix = "prefixfunctionaltest-"; //have to randomize the string to post
string title = "Functiontest Title";
string parentUri = "http://www.bbc.co.uk/dna/h2g2/";
string id = string.Empty;
string url = string.Empty;
string commentForumXml = string.Empty;
XmlDocument xml = null;
DnaXmlValidator validator = null;
CommentForum returnedForum = null;
for (int i = 0; i < 3; i++)
{
id = prefix + Guid.NewGuid();
commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
"<id>{0}</id>" +
"<title>{1}</title>" +
"<parentUri>{2}</parentUri>" +
"</commentForum>", id, title, parentUri);
// Setup the request url
url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
_sitename);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
// Check to make sure that the page returned with the correct information
// Check to make sure that the page returned with the correct information
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
returnedForum =
(CommentForum)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForum));
Assert.IsTrue(returnedForum.Id == id);
}
//create a non-prefixed one
id = Guid.NewGuid().ToString();
commentForumXml = String.Format("<commentForum xmlns=\"BBC.Dna.Api\">" +
"<id>{0}</id>" +
"<title>{1}</title>" +
"<parentUri>{2}</parentUri>" +
"</commentForum>", id, title, parentUri);
// Setup the request url
url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/", _sitename);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
// Check to make sure that the page returned with the correct information
// Check to make sure that the page returned with the correct information
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
returnedForum =
(CommentForum) StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForum));
Assert.IsTrue(returnedForum.Id == id);
// Setup the request url
url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/?prefix={1}",
_sitename, prefix);
// now get the response
request.RequestPageWithFullURL(url, "", "text/xml");
// Check to make sure that the page returned with the correct information
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList);
validator.Validate();
var returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList != null);
Console.WriteLine("After GetCommentForumsBySitenameXML");
string sortBy = SortBy.Created.ToString();
string sortDirection = SortDirection.Ascending.ToString();
string sortUrl = url + "&sortBy={0}&sortDirection={1}";
//test ascending created
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.SortBy.ToString() == sortBy);
DateTime prevCreate = DateTime.MinValue;
DateTime currentDate = DateTime.MinValue;
for (int i = 0; i < returnedList.CommentForums.Count; i++)
{
currentDate = DateTime.Parse(returnedList.CommentForums[i].Created.At);
Assert.IsTrue(currentDate >= prevCreate);
//.........这里部分代码省略.........
示例12: GetCommentForumsBySitenameXML_WithSorting_ByPostCount
public void GetCommentForumsBySitenameXML_WithSorting_ByPostCount()
{
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/",
_sitename);
// now get the response
request.RequestPageWithFullURL(url, "", "text/xml");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForumList);
validator.Validate();
string sortBy = SortBy.PostCount.ToString();
string sortDirection = SortDirection.Ascending.ToString();
string sortUrl = url + "?sortBy={0}&sortDirection={1}";
//test ascending created
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
var returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.SortBy.ToString() == sortBy);
int prevTotal = 0;
int currentTotal;
for (int i = 0; i < returnedList.CommentForums.Count; i++)
{
currentTotal = returnedList.CommentForums[i].commentSummary.Total;
Assert.IsTrue(currentTotal >= prevTotal);
prevTotal = currentTotal;
}
//test descending created
sortBy = SortBy.PostCount.ToString();
sortDirection = SortDirection.Descending.ToString();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.SortBy.ToString() == sortBy);
prevTotal = int.MaxValue;
for (int i = 0; i < returnedList.CommentForums.Count; i++)
{
currentTotal = returnedList.CommentForums[i].commentSummary.Total;
Assert.IsTrue(currentTotal <= prevTotal);
prevTotal = currentTotal;
}
//test descending created case insensitive
sortBy = SortBy.PostCount.ToString();
sortDirection = SortDirection.Ascending.ToString().ToLower();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList.SortDirection.ToString() != sortDirection); // should fail and return the default
Assert.IsTrue(returnedList.SortDirection.ToString() == SortDirection.Ascending.ToString());
// should fail and return the default
Assert.IsTrue(returnedList.SortBy.ToString() == sortBy);
prevTotal = 0;
for (int i = 0; i < returnedList.CommentForums.Count; i++)
{
currentTotal = returnedList.CommentForums[i].commentSummary.Total;
Assert.IsTrue(currentTotal >= prevTotal);
prevTotal = currentTotal;
}
//test sort by created case insensitive
sortBy = SortBy.PostCount.ToString().ToLower();
sortDirection = SortDirection.Descending.ToString();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList =
(CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof (CommentForumList));
Assert.IsTrue(returnedList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.SortBy.ToString() != sortBy);
// should fail and return the default which is Created
Assert.AreEqual(SortBy.Created, returnedList.SortBy);
// should fail and return the default which is Created
}
示例13: GetCommentForumWithCommentId_CreateAndAscending_ReturnsCorrectPost
public void GetCommentForumWithCommentId_CreateAndAscending_ReturnsCorrectPost()
{
var sortBy = SortBy.Created;
var sortDirection = SortDirection.Ascending;
var expectedStartIndex = 2;
var itemsPerPage = 1;
//create the forum
CommentForum commentForum = CommentForumCreateHelper();
//Create 2 Comments in the same forum.
var comments = new CommentsTests_V1();
CommentInfo commentInfo = comments.CreateCommentHelper(commentForum.Id);
CommentInfo commentInfo2 = comments.CreateCommentHelper(commentForum.Id);
CommentInfo commentInfo3 = comments.CreateCommentHelper(commentForum.Id);
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?includepostid={2}&sortBy={3}&sortDirection={4}&itemsPerPage={5}",
_sitename, commentForum.Id, commentInfo3.ID, sortBy, sortDirection, itemsPerPage);
// now get the response
request.RequestPageWithFullURL(url, "", "text/xml");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
var returnedForum =
(CommentForum)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentForum));
Assert.AreEqual(expectedStartIndex, returnedForum.commentList.StartIndex);
Assert.AreEqual(itemsPerPage, returnedForum.commentList.ItemsPerPage);
Assert.AreEqual(commentInfo3.ID, returnedForum.commentList.comments[0].ID);
}
示例14: GetCommentForumsBySitenameXML_WithTimeFrameFilter
public void GetCommentForumsBySitenameXML_WithTimeFrameFilter()
{
SnapshotInitialisation.ForceRestore();//must be clean here...
var request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
// Filter forum on editors picks filter
var url =
String.Format(
"http://{0}/dna/api/comments/CommentsService.svc/V1/site/{1}/?filterBy={2}", _server, _sitename, FilterBy.PostsWithinTimePeriod);
//create the forum
var commentForum = CommentForumCreateHelper();
//Create 1 Comments in the same forum.
var comments = new CommentsTests_V1();
var commentInfo = comments.CreateCommentHelper(commentForum.Id);
//get the latest list
request.RequestPageWithFullURL(url, "", "text/xml");
var returnedObj = (CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentForumList));
Assert.IsNotNull(returnedObj);
Assert.AreEqual(FilterBy.PostsWithinTimePeriod, returnedObj.FilterBy);
Assert.AreEqual(SortBy.PostCount, returnedObj.SortBy);
Assert.AreEqual(1, returnedObj.TotalCount);
url += "&timeperiod=0";
request.RequestPageWithFullURL(url, "", "text/xml");
returnedObj = (CommentForumList)
StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(CommentForumList));
Assert.IsNotNull(returnedObj);
Assert.AreEqual(FilterBy.PostsWithinTimePeriod, returnedObj.FilterBy);
Assert.AreEqual(SortBy.PostCount, returnedObj.SortBy);
Assert.AreEqual(0, returnedObj.TotalCount);
}
示例15: makeRequest
// =============================================================================================
/// <summary>
/// Does all the work
/// </summary>
private DnaTestURLRequest makeRequest(string formatParam, String file, String postData, String mimeType)
{
DnaTestURLRequest request = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
request.SetCurrentUserEditor();
String url = "http://" + testUtils_CommentsAPI.server + "/dna/api/comments/CommentsService.svc/v1/site/" + testUtils_CommentsAPI.sitename + "/" + file + "?format=" + formatParam;
// now get the response - minimal POST data, no clue about the input mime-type , user is not allowed, however
try
{
request.RequestPageWithFullURL(url, postData, mimeType);
}
catch
{
string respStr = request.GetLastResponseAsString();
}
return request;
} // ends makeRequest