本文整理汇总了C#中Tests.DnaTestURLRequest.SetCurrentUserModerator方法的典型用法代码示例。如果您正苦于以下问题:C# DnaTestURLRequest.SetCurrentUserModerator方法的具体用法?C# DnaTestURLRequest.SetCurrentUserModerator怎么用?C# DnaTestURLRequest.SetCurrentUserModerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.SetCurrentUserModerator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestModerationEvent
public void TestModerationEvent()
{
DnaTestURLRequest request = new DnaTestURLRequest("moderation");
request.SetCurrentUserModerator();
//Put an item into moderation queue and moderate it.
IInputContext context = DnaMockery.CreateDatabaseInputContext();
String sql = String.Format("EXECUTE addexlinktomodqueue @siteid={0}, @uri='{1}', @callbackuri='{2}', @notes='{3}'",1, "http://localhost:8089/", "http://localhost:8089/", "Test");
int modId = 0;
using (IDnaDataReader dataReader = context.CreateDnaDataReader(sql))
{
dataReader.ExecuteDEBUGONLY(sql);
dataReader.ExecuteDEBUGONLY(String.Format("EXEC getmoderationexlinks @modclassid=0, @referrals=0,@alerts=0, @locked=0, @userid={0}", request.CurrentUserID));
dataReader.Read();
modId = dataReader.GetInt32NullAsZero("modid");
dataReader.ExecuteDEBUGONLY(String.Format("EXECUTE moderateexlinks @modid={0}, @userid={1},@decision={2},@notes='{3}',@referto={4}", modId, request.CurrentUserID, 3, "Testing", 0));
//Process Event Queue
dataReader.ExecuteDEBUGONLY("EXECUTE processeventqueue");
}
//Wait up to 10 seconds for callback.
if (_thread.IsAlive)
{
_thread.Join(60000);
}
//Check Moderation Item has been processed.
Assert.IsTrue( _callbackBody.Contains(Convert.ToString(modId)),"Checking value of returned ModId. In order for this test to work the SNESEventProcessor Service must be running against Small Guide.");
}
示例2: GetCallingUserInfo_AsModerator_ReturnsModeratorItemInGroup
public void GetCallingUserInfo_AsModerator_ReturnsModeratorItemInGroup()
{
Console.WriteLine("Before GetCallingUserInfo_AsModerator_ReturnsModeratorItemInGroup");
DnaTestURLRequest request = new DnaTestURLRequest("h2g2");
request.SetCurrentUserModerator();
request.RequestPageWithFullURL(callinguser_url);
BBC.Dna.Users.User user = (BBC.Dna.Users.User)StringUtils.DeserializeObject(request.GetLastResponseAsXML().OuterXml, typeof(BBC.Dna.Users.User));
Assert.IsTrue(user.UsersListOfGroups.Exists(x => x.Name.ToLower() == "moderator"));
Console.WriteLine("After GetCallingUserInfo_AsModerator_ReturnsModeratorItemInGroup");
}
示例3: GetReviewForumXML_WithSorting_ByCreated
public void GetReviewForumXML_WithSorting_ByCreated()
{
BBC.Dna.Api.RatingForum returnedForum = CreateRatingForum();
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
string url = String.Empty;
request.SetCurrentUserEditor();
//create 10 comments
for (int i = 0; i < 3; i++)
{
string text = "Functiontest Title" + Guid.NewGuid().ToString();
string commentXml = String.Format("<comment xmlns=\"BBC.Dna.Api\">" +
"<text>{0}</text>" +
"<rating>{1}</rating>" +
"</comment>", text, 5);
// Setup the request url
url = String.Format("https://" + _secureserver + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, returnedForum.Id);
//change the user for a review...
switch(i)
{
case 1: request.SetCurrentUserModerator(); break;
case 2: request.SetCurrentUserNormal(); break;
}
// now get the response
request.RequestPageWithFullURL(url, commentXml, "text/xml");
}
//////////////////////////////
//set up sorting tests
//////////////////////////////
url = String.Format("http://" + _server + "/dna/api/comments/ReviewService.svc/V1/site/{0}/reviewforum/{1}/", _sitename, returnedForum.Id);
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");
BBC.Dna.Api.RatingForum returnedList = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
Assert.IsTrue(returnedList.ratingsList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.ratingsList.SortBy.ToString() == sortBy);
DateTime prevCreate = DateTime.MinValue;
DateTime currentDate = DateTime.MinValue;
for (int i = 0; i < returnedList.ratingsList.ratings.Count; i++)
{
currentDate = DateTime.Parse(returnedList.ratingsList.ratings[i].Created.At);
Assert.IsTrue(currentDate >= prevCreate);
prevCreate = currentDate;
}
//test descending created
sortBy = SortBy.Created.ToString();
sortDirection = SortDirection.Descending.ToString();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
Assert.IsTrue(returnedList.ratingsList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.ratingsList.SortBy.ToString() == sortBy);
prevCreate = DateTime.MaxValue;
for (int i = 0; i < returnedList.ratingsList.ratings.Count; i++)
{
currentDate = DateTime.Parse(returnedList.ratingsList.ratings[i].Created.At);
Assert.IsTrue(currentDate <= prevCreate);
prevCreate = currentDate;
}
//test descending created case insensitive
sortBy = SortBy.Created.ToString();
sortDirection = SortDirection.Descending.ToString().ToLower();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
Assert.IsTrue(returnedList.ratingsList.SortDirection.ToString() != sortDirection);// should fail and return the default
Assert.IsTrue(returnedList.ratingsList.SortDirection.ToString() == SortDirection.Ascending.ToString());// should fail and return the default
Assert.IsTrue(returnedList.ratingsList.SortBy.ToString() == sortBy);
prevCreate = DateTime.MinValue;
for (int i = 0; i < returnedList.ratingsList.ratings.Count; i++)
{
currentDate = DateTime.Parse(returnedList.ratingsList.ratings[i].Created.At);
Assert.IsTrue(currentDate >= prevCreate);
prevCreate = currentDate;
}
//test sort by created case insensitive
sortBy = SortBy.Created.ToString().ToLower();
sortDirection = SortDirection.Descending.ToString();
request.RequestPageWithFullURL(String.Format(sortUrl, sortBy, sortDirection), "", "text/xml");
returnedList = (BBC.Dna.Api.RatingForum)StringUtils.DeserializeObject(request.GetLastResponseAsString(), typeof(BBC.Dna.Api.RatingForum));
Assert.IsTrue(returnedList.ratingsList.SortDirection.ToString() == sortDirection);
Assert.IsTrue(returnedList.ratingsList.SortBy.ToString() != sortBy);// should fail and return the default which is Created
Assert.IsTrue(returnedList.ratingsList.SortBy.ToString() == SortBy.Created.ToString());// should fail and return the default which is Created
prevCreate = DateTime.MaxValue;
for (int i = 0; i < returnedList.ratingsList.ratings.Count; i++)
{
currentDate = DateTime.Parse(returnedList.ratingsList.ratings[i].Created.At);
Assert.IsTrue(currentDate <= prevCreate);
prevCreate = currentDate;
}
//.........这里部分代码省略.........
示例4: getThePostIds
/// <summary>
/// reads the moderate posts page
/// </summary>
/// <param name="toShow">how manu items to show</param>
/// <returns>the page as XML</returns>
private XmlNodeList getThePostIds(int toShow, int modClassOfSite)
{
string url = "http://" + testUtils_CommentsAPI.server + "/dna/moderation/moderateposts?modclassid=";
url += modClassOfSite;
url += "&s_classview=3&fastmod=0¬fastmod=0?skin=purexml";
url += "&show=" + toShow.ToString();
DnaTestURLRequest myRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
myRequest.SetCurrentUserModerator();
myRequest.UseEditorAuthentication = true; ;
myRequest.RequestPageWithFullURL(url, "", "");
/* have to comment this out because teh schema is not a match of the output
// just make sure that we are getting what we want
DnaXmlValidator validator = new DnaXmlValidator(myRequest.GetLastResponseAsXML().InnerXml, "H2G2ModeratePosts.xsd");
validator.Validate();
*/
XmlDocument xml = myRequest.GetLastResponseAsXML();
return xml.SelectNodes("//@POSTID"); ;
}
示例5: makeTestItem
public static int maxNumDiffUsers = 5; // different users as avaialble below
public static string makeTestItem(string forumId, int index)
{
System.Random RandNum = new System.Random();
int inputRating = RandNum.Next(1, 5);
string ratingString = "";
string ratingScore = "";
string postData = testUtils_ratingsAPI.makeEntryPostXml_minimal(ref ratingString, ref ratingScore);
string url = makeCreatePostUrl(forumId);
DnaTestURLRequest theRequest = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
theRequest.UseIdentitySignIn = true;
switch (index)
{
case 0: theRequest.SetCurrentUserNormal(); break;
case 1: theRequest.SetCurrentUserNotableUser(); break;
case 2: theRequest.SetCurrentUserModerator(); break;
case 3: theRequest.SetCurrentUserProfileTest(); break;
case 4: theRequest.SetCurrentUserEditor(); break;
default: Assert.Fail("Can only set up 5 different users. Other users are particularly special"); break;
}
try
{
theRequest.RequestPageWithFullURL(url, postData, "text/xml");
}
catch
{
string resp = theRequest.GetLastResponseAsString();
}
Assert.IsTrue(theRequest.CurrentWebResponse.StatusCode == HttpStatusCode.OK,
"Error making test rating entity. Expecting " + HttpStatusCode.OK +
" as response, got " + theRequest.CurrentWebResponse.StatusCode + "\n" +
theRequest.CurrentWebResponse.StatusDescription
);
RatingInfo inf = (RatingInfo)StringUtils.DeserializeObject(theRequest.GetLastResponseAsString(), typeof(RatingInfo));
return inf.ID.ToString();
}
示例6: CreateCommentsWithDifferentRatingsAndValidate
private void CreateCommentsWithDifferentRatingsAndValidate(int apiVersion)
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
CommentForum commentForum = new CommentForum();
CommentInfo commentInfo = new CommentInfo();
CommentInfo commentInfo2 = new CommentInfo();
CreateTestForumAndComment(ref commentForum, ref commentInfo);
CreateTestForumAndComment(ref commentForum, ref commentInfo2);
string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V{3}/site/{0}/commentsforums/{1}/comment/{2}/rate/up", _sitename, commentForum.Id, commentInfo.ID, apiVersion);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
//Assert.AreEqual("1", xml.DocumentElement.InnerText);
if (apiVersion == 1)
{
Assert.AreEqual("1", xml.DocumentElement.InnerText);
}
else if (apiVersion == 2)
{
var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
Assert.AreEqual(1, neroRatingInfo.neroValue);
Assert.AreEqual(1, neroRatingInfo.positiveNeroValue);
Assert.AreEqual(0, neroRatingInfo.negativeNeroValue);
}
else
{
Assert.Fail("We don't support any other version than 1 or 2");
}
request.SetCurrentUserModerator();
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
xml = request.GetLastResponseAsXML();
//Assert.AreEqual("2", xml.DocumentElement.InnerText);
if (apiVersion == 1)
{
Assert.AreEqual("2", xml.DocumentElement.InnerText);
}
else if (apiVersion == 2)
{
var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
Assert.AreEqual(2, neroRatingInfo.neroValue);
Assert.AreEqual(2, neroRatingInfo.positiveNeroValue);
Assert.AreEqual(0, neroRatingInfo.negativeNeroValue);
}
else
{
Assert.Fail("We don't support any other version than 1 or 2");
}
request.SetCurrentUserNotableUser();
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V{3}/site/{0}/commentsforums/{1}/comment/{2}/rate/down", _sitename, commentForum.Id, commentInfo2.ID, apiVersion);
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
xml = request.GetLastResponseAsXML();
//Assert.AreEqual("-1", xml.DocumentElement.InnerText);
if (apiVersion == 1)
{
Assert.AreEqual("-1", xml.DocumentElement.InnerText);
}
else if (apiVersion == 2)
{
var neroRatingInfo = (NeroRatingInfo)StringUtils.DeserializeObject(xml.InnerXml, typeof(NeroRatingInfo));
Assert.AreEqual(-1, neroRatingInfo.neroValue);
Assert.AreEqual(0, neroRatingInfo.positiveNeroValue);
Assert.AreEqual(-1, neroRatingInfo.negativeNeroValue);
}
else
{
Assert.Fail("We don't support any other version than 1 or 2");
}
//test as ascending
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Ascending);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml");
xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
var returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[0].ID);
Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[1].ID);
//test as ascending
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Descending);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml");
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[0].ID);
Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[1].ID);
}
示例7: TestRecacheGroupsVia_gc
public void TestRecacheGroupsVia_gc()
{
// First check to make sure that a given test group is not pressent
DnaTestURLRequest request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserEditor();
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&xyzzy=1");
DnaXmlValidator validator = new DnaXmlValidator(request.GetLastResponseAsXML().OuterXml, "H2G2CommentBoxFlat.xsd");
validator.Validate();
// Make a copy of the user groups so we can put then back at the end of this test
XmlNodeList groupnodes = request.GetLastResponseAsXML().SelectNodes("H2G2/VIEWING-USER/USER/GROUPS/GROUP/NAME");
foreach (XmlNode node in groupnodes)
{
// Add the group name to the list
_userGroups.Add(node.InnerText);
}
CheckResponseForGroups(request, "EDITOR", true, true, "FORMERSTAFF", false, false);
// At this point, we need to make sure that the teardown function will corrctly put the user back into the original groups
_reapplyGroupsForUserID = request.CurrentUserID;
// Now add the user to the new group via the database
AddUserToGroup(_reapplyGroupsForUserID, GetIDForSiteName(), "FormerStaff", false);
// Now make sure that the users group information has not changed for the comment, but has for the viewing user block
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&xyzzy=2");
CheckResponseForGroups(request, "EDITOR", true, true, "FORMERSTAFF", true, false);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='FORMERSTAFF']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='FORMERSTAFF']") == null);
// Now send the refresh cache request and make sure that the users group info has been updated
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&_gc=1&xyzzy=3");
CheckResponseForGroups(request, "EDITOR", true, true, "FORMERSTAFF", true, true);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='FORMERSTAFF']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='FORMERSTAFF']") != null);
// Now remove the user from the group via the database and reaply the original groups
AddUserToGroups(_reapplyGroupsForUserID, GetIDForSiteName(), _userGroups, true);
// We've managed to put the user back into their original groups, so don't make the teardowen function do the same work twice
_reapplyGroupsForUserID = 0;
// Now send the refresh cache request and make sure that the users group info has been updated
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&_gc=1");
CheckResponseForGroups(request, "EDITOR", true, true, "FORMERSTAFF", false, false);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='FORMERSTAFF']") == null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='EDITOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='FORMERSTAFF']") == null);
// Extra tests to see if the signal with single-user effect works
// We test for two different users - editor and moderator
// first make a normal request for the moderator page, and check all is well. Also save the groups they are currently in
// Save the current user ID
int editorUserID = request.CurrentUserID;
request.SetCurrentUserModerator();
int moderatorUserId = request.CurrentUserID;
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&xyzzy=4");
CheckResponseForGroups(request, "MODERATOR", true, true, "FORMERSTAFF", false, false);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='MODERATOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/VIEWING-USER/USER/GROUPS/GROUP[NAME='FORMERSTAFF']") == null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='MODERATOR']") != null);
//Assert.IsTrue(request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']/GROUPS/GROUP[NAME='FORMERSTAFF']") == null);
// Save this user's groups
List<string> moderatorsGroups = new List<string>();
groupnodes = request.GetLastResponseAsXML().SelectNodes("H2G2/VIEWING-USER/USER/GROUPS/GROUP/NAME");
foreach (XmlNode node in groupnodes)
{
// Add the group name to the list
moderatorsGroups.Add(node.InnerText);
}
// Now add the users to the new group via the database
AddUserToGroup(editorUserID, GetIDForSiteName(), "FormerStaff", false);
AddUserToGroup(moderatorUserId, GetIDForSiteName(), "FormerStaff", false);
// Now check, for each of these users, that the cached user info is wrong, but ViewingUser is correct
request.SetCurrentUserModerator();
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&xyzzy=5");
CheckResponseForGroups(request, "MODERATOR", true, true, "FORMERSTAFF", true, false);
request.SetCurrentUserEditor();
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&skin=purexml&xyzzy=6");
CheckResponseForGroups(request, "EDITOR", true, true, "FORMERSTAFF", true, false);
//.........这里部分代码省略.........
示例8: SetupTestData
/// <summary>
/// Setupo function tomake sure that there is at least one comment in a comment box by the test user
/// </summary>
private void SetupTestData()
{
// Check to see if the test user has created a post in a comment box
//IInputContext inputContext = new StoredProcedureTestInputContext();
//using (IDnaDataReader dataReader = inputContext.CreateDnaDataReader("addusertogroups"))
//{
//}
DnaTestURLRequest request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserEditor();
request.RequestPage(@"DnaSignal?action=recache-groups");
request.RequestPage(@"acs?dnauid=RecacheUserGroupsTestForum&dnainitialtitle=UserGroupTest&dnahostpageurl=http://localhost.bbc.co.uk/usergrouptestforum&skin=purexml");
if (request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']") == null)
{
// We need to add a comment!
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&dnaaction=add&dnacomment=Userposting&skin=purexml");
}
request.SetCurrentUserModerator();
if (request.GetLastResponseAsXML().SelectSingleNode("H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST/USER[USERNAME='" + request.CurrentUserName + "']") == null)
{
// We need to add a comment!
request.RequestPage("acs?dnauid=RecacheUserGroupsTestForum&dnaaction=add&dnacomment=Userposting2&skin=purexml");
}
}
示例9: TestCreateNewUnicodeCommentComplain
public void TestCreateNewUnicodeCommentComplain()
{
Console.WriteLine("Before CommentBoxTests - TestCreateNewUnicodeCommentComplain");
DnaTestURLRequest request = new DnaTestURLRequest("haveyoursay");
request.SetCurrentUserNormal();
// Setup the request url
string uid = Guid.NewGuid().ToString();
string encodedTitle = "TestCreateNewUnicodeCommentComplain - \u041D\u0435 \u043F\u0430\u043D\u0438\u043A\u0443\u0439\u0442\u0435";
string hosturl = "http://" + _server + "/dna/haveyoursay/acs";
string url = "acswithoutapi?dnauid=" + uid + "&dnainitialtitle=" + encodedTitle + "&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.InnerXml, _schemaUri);
validator.Validate();
Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
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");
string comment = "ComplainAboutThis\u4E0D\u8981\u6050\u614C works too now as well as well as \u041D\u0435 \u043F\u0430\u043D\u0438\u043A\u0443\u0439\u0442\u0435 \u00A3 \u0024 \u0025";
// Now check to make sure we can post to the comment box
//The unicode string just goes in as it is to come out not sure this will fully test how the string will come from the skins
request.RequestSecurePage("acswithoutapi?dnauid=" + uid + "&dnaaction=add&dnacomment=" + comment + "&dnahostpageurl=" + hosturl + "&skin=purexml");
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
validator.Validate();
Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX") != null, "Comment box tag does not exist!");
Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS").Attributes["FORUMPOSTCOUNT"].Value == "1", "The forum should have 1 post!");
Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST") != null, "Failed to post a comment!!!");
Assert.IsTrue(xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST[TEXT='" + comment + "']") != null, "Posted comment did not appear!!!");
string postID = xml.SelectSingleNode("/H2G2/COMMENTBOX/FORUMTHREADPOSTS/POST").Attributes["POSTID"].Value;
//COMPLAIN ABOUT IT
//request.SetCurrentUserNotLoggedInUser();
request.RequestPage("UserComplaintPage?postid=" + postID + "&action=submit&complaintreason=libellous&complainttext=Complaint&[email protected]&skin=purexml");
xml = request.GetLastResponseAsXML();
// Check to make sure complaint was processed
Assert.IsTrue(xml.SelectSingleNode("//H2G2/USERCOMPLAINT/@MODID") != null, "Complaint did not succeed");
//PUT the moderator into a moderation class
IInputContext context = DnaMockery.CreateDatabaseInputContext();
using (IDnaDataReader reader = context.CreateDnaDataReader(""))
{
reader.ExecuteDEBUGONLY("insert into moderationclassmembers (ModClassID, UserID) values (1, 1090564231)");
}
request.SetCurrentUserModerator();
request.UseEditorAuthentication = true;
request.RequestPage("moderateposts?modclassid=1&s_classview=1&alerts=1&fastmod=0¬fastmod=0&skin=purexml");
xml = request.GetLastResponseAsXML();
Assert.IsTrue(xml.SelectSingleNode("/H2G2/POSTMODERATION/POST[TEXT='" + comment + "']") != null, "Complained about comment did not appear correctly!!!");
Console.WriteLine("After CommentBoxTests - TestCreateNewUnicodeCommentComplain");
}
示例10: RateUpComment_SortByRatingValue_ReturnsCorrectOrder
public void RateUpComment_SortByRatingValue_ReturnsCorrectOrder()
{
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
CommentForum commentForum = new CommentForum();
CommentInfo commentInfo = new CommentInfo();
CommentInfo commentInfo2 = new CommentInfo();
CreateTestForumAndComment(ref commentForum, ref commentInfo);
CreateTestForumAndComment(ref commentForum, ref commentInfo2);
string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/comment/{2}/rate/up", _sitename, commentForum.Id, commentInfo.ID);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
// Check to make sure that the page returned with the correct information
XmlDocument xml = request.GetLastResponseAsXML();
Assert.AreEqual("1", xml.DocumentElement.InnerText);
request.SetCurrentUserModerator();
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
xml = request.GetLastResponseAsXML();
Assert.AreEqual("2", xml.DocumentElement.InnerText);
request.SetCurrentUserNotableUser();
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/comment/{2}/rate/down", _sitename, commentForum.Id, commentInfo2.ID);
request.RequestPageWithFullURL(url, null, "text/xml", "PUT");
xml = request.GetLastResponseAsXML();
Assert.AreEqual("-1", xml.DocumentElement.InnerText);
//test as ascending
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Ascending);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml");
xml = request.GetLastResponseAsXML();
var validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
var returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[0].ID);
Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[1].ID);
//test as ascending
url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?sortBy={2}&sortDirection={3}", _sitename, commentForum.Id, SortBy.RatingValue, SortDirection.Descending);
// now get the response
request.RequestPageWithFullURL(url, null, "text/xml");
xml = request.GetLastResponseAsXML();
validator = new DnaXmlValidator(xml.InnerXml, _schemaCommentForum);
validator.Validate();
returnedForum = (CommentForum)StringUtils.DeserializeObject(xml.InnerXml, typeof(CommentForum));
Assert.AreEqual(commentInfo.ID, returnedForum.commentList.comments[0].ID);
Assert.AreEqual(commentInfo2.ID, returnedForum.commentList.comments[1].ID);
}