本文整理匯總了C#中Tests.DnaTestURLRequest.SetCurrentUserEditor方法的典型用法代碼示例。如果您正苦於以下問題:C# DnaTestURLRequest.SetCurrentUserEditor方法的具體用法?C# DnaTestURLRequest.SetCurrentUserEditor怎麽用?C# DnaTestURLRequest.SetCurrentUserEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tests.DnaTestURLRequest
的用法示例。
在下文中一共展示了DnaTestURLRequest.SetCurrentUserEditor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UserListTests
/// <summary>
/// Constructor for the User Tests to set up the context for the tests
/// </summary>
public UserListTests()
{
string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
BBC.Dna.AppContext.OnDnaStartup(rootPath);
Console.WriteLine("Before RecentSearch - AddRecentSearchTests");
//Create the mocked _InputContext
Mockery mock = new Mockery();
_InputContext = DnaMockery.CreateDatabaseInputContext();
// Create a mocked site for the context
ISite mockedSite = DnaMockery.CreateMockedSite(_InputContext, 1, "h2g2", "h2g2", true, "comment");
Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
Stub.On(mockedSite).GetProperty("ModClassID").Will(Return.Value(1));
BBC.Dna.User user = new BBC.Dna.User(_InputContext);
Stub.On(_InputContext).GetProperty("ViewingUser").Will(Return.Value(user));
Stub.On(_InputContext).GetProperty("CurrentSite").Will(Return.Value(mockedSite));
//Create sub editor group and users
//create test sub editors
DnaTestURLRequest dnaRequest = new DnaTestURLRequest("h2g2");
dnaRequest.SetCurrentUserEditor();
TestDataCreator testData = new TestDataCreator(_InputContext);
int[] userIDs = new int[10];
Assert.IsTrue(testData.CreateNewUsers(mockedSite.SiteID, ref userIDs), "Test users not created");
Assert.IsTrue(testData.CreateNewUserGroup(dnaRequest.CurrentUserID, "subs"), "CreateNewUserGroup not created");
Assert.IsTrue(testData.AddUsersToGroup(userIDs, mockedSite.SiteID, "subs"), "Unable to add users to group not created");
}
示例2: NoData
public void NoData()
{
Console.WriteLine("Before missingData - NoData");
// test variant data
string postData = "";
string mimeType = "";
string url = "http://" + testUtils_CommentsAPI.server + "/dna/api/comments/CommentsService.svc/v1/site/";
//HttpStatusCode expectedHttpResponse = HttpStatusCode.OK;
// consistent input data
// working data
DnaTestURLRequest request = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
request.SetCurrentUserEditor();
// now get the response - no POST data, nor any clue about the type
try
{
request.RequestPageWithFullURL(url, postData, mimeType);
}
catch
{// Check to make sure that the page returned with the correct information
Assert.IsTrue(request.CurrentWebResponse.StatusCode == HttpStatusCode.NotFound);
}
Console.WriteLine("After missingData - NoData");
} // ends NoData
示例3: CreateEditorsPick
public void CreateEditorsPick()
{
//First get a comment.
CommentsTests_V1 comments = new CommentsTests_V1();
CommentForumTests_V1 commentForums = new CommentForumTests_V1();
_commentInfo = comments.CreateCommentHelper(commentForums.CommentForumCreateHelper().Id);
Assert.IsNotNull(_commentInfo, "Unable to Create Comment");
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserEditor();
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/comments/{1}/editorpicks/", _sitename,_commentInfo.ID);
request.RequestPageWithFullURL(url, "No data to send", "text/xml");
//Check for Editors Pick presence.
url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/comments/?filterBy=EditorPicks", _sitename);
request.RequestPageWithFullURL(url);
XmlDocument xml = request.GetLastResponseAsXML();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("api", "BBC.Dna.Api");
String xPath = String.Format("api:commentsList/api:comments/api:comment[api:id='{0}']", _commentInfo.ID);
XmlNode pick = xml.SelectSingleNode(xPath, nsmgr);
Assert.IsNotNull(pick);
}
示例4: bbActivateBoard
public void bbActivateBoard()
{
aaCreateTopic();
Console.WriteLine("Before bbActivateBoard");
//Activate Board
string url = "Messageboardadmin?cmd=activateboard&skin=purexml";
DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay");
urlRequest.SetCurrentUserEditor();
urlRequest.UseEditorAuthentication = true;
urlRequest.RequestPage(url);
XmlDocument doc = urlRequest.GetLastResponseAsXML();
Assert.IsNotNull(doc.SelectSingleNode("/H2G2[BOARDACTIVATED='1']"), "Check Board Activated");
url = "frontpage?skin=purexml";
urlRequest.RequestPage(url);
doc = urlRequest.GetLastResponseAsXML();
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']"), "Check topic published");
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TOPICLINKID='" + topicPreviewID + "']"), "Check Preview Topic Link");
XmlNode node = doc.SelectSingleNode("/H2G2/TOPICLIST/TOPIC[TITLE='" + topicName + "']/FORUMID");
if (node != null)
{
topicForumID = node.InnerText;
}
//Check Topic Forum Is Writable.
url = "F" + topicForumID + "&skin=purexml";
urlRequest.RequestPage(url);
doc = urlRequest.GetLastResponseAsXML();
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMSOURCE/ARTICLE/ARTICLEINFO[FORUMID='" + topicForumID + "']"), "Check Topic ForumId");
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANREAD='1']"), "Check Read Permissions");
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/FORUMTHREADS[@CANWRITE='1']"), "Check Write Permissions");
Console.WriteLine("After bbActivateBoard");
}
示例5: aaCreateTopic
public void aaCreateTopic()
{
Console.WriteLine("Before aaCreateTopic");
topicName = "CreateTopic" + Convert.ToString(DateTime.Now.Ticks);
string url = "TopicBuilder?_msfinish=yes&_msstage=1&_msxml=+%0D%0A%09%3CMULTI-INPUT%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TITLE%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXT%27%3E%3CVALIDATE+TYPE%3D%27EMPTY%27+%2F%3E%3C%2FREQUIRED%3E%0D%0A%09%09%3CREQUIRED+NAME%3D%27TEXTTYPE%27+%3E%3C%2FREQUIRED%3E%09%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27TOPICID%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%09%3CREQUIRED+NAME%3D%27EDITKEY%27%3E%3C%2FREQUIRED%3E%09%0D%0A%09%3C%2FMULTI-INPUT%3E%0D%0A+&cmd=create&title=" + topicName + "&text=TestBody" + topicName + "&save=+save++&skin=purexml";
DnaTestURLRequest urlRequest = new DnaTestURLRequest("haveyoursay");
urlRequest.SetCurrentUserEditor();
urlRequest.UseEditorAuthentication = true;
urlRequest.RequestPage(url);
XmlDocument doc = urlRequest.GetLastResponseAsXML();
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[TYPE='created']"),"Check Topic Creation");
Assert.IsNotNull(doc.SelectSingleNode("/H2G2/TOPIC_PAGE/ACTION[OBJECT='" + topicName + "']"),"Check Topic Creation");
Assert.IsNull(doc.SelectSingleNode("/H2G2/ERROR"),"Error in Page");
XmlNode node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/EDITKEY");
if ( node != null )
{
topicEditKey = node.InnerText;
}
node = doc.SelectSingleNode("/H2G2/TOPIC_PAGE/TOPICLIST/TOPIC[TITLE='" + topicName + "']/TOPICID");
if ( node != null )
{
topicPreviewID = node.InnerText;
}
Console.WriteLine("After aaCreateTopic");
}
示例6: EditPost_DoEdit_ReturnsEdittedPost
public void EditPost_DoEdit_ReturnsEdittedPost()
{
DnaTestURLRequest request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserEditor();
var xml = GetPost(request, @"editpost?skin=purexml&postid=" + _postId.ToString());
Assert.IsNull(xml.SelectSingleNode("H2G2/ERROR"));
Assert.IsNotNull(xml.SelectSingleNode("H2G2/POST-EDIT-FORM"));
var editForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm));
Assert.AreEqual(_postId, editForm.PostId);
var postParams = new Queue<KeyValuePair<string, string>>();
postParams = new Queue<KeyValuePair<string, string>>();
postParams.Enqueue(new KeyValuePair<string, string>("PostID", editForm.PostId.ToString()));
postParams.Enqueue(new KeyValuePair<string, string>("Subject", editForm.Subject + "1"));
postParams.Enqueue(new KeyValuePair<string, string>("Text", editForm.Text + "1"));
postParams.Enqueue(new KeyValuePair<string, string>("Update", "Update"));
postParams.Enqueue(new KeyValuePair<string, string>("hidePostReason", ""));
postParams.Enqueue(new KeyValuePair<string, string>("notes", "test"));
request.RequestPage("editpost?skin=purexml", false, postParams);
xml = request.GetLastResponseAsXML();
var returnedForm = (PostEditForm)StringUtils.DeserializeObjectUsingXmlSerialiser(xml.SelectSingleNode("H2G2/POST-EDIT-FORM").OuterXml, typeof(PostEditForm));
Assert.AreEqual(_postId, returnedForm.PostId);
Assert.AreEqual(editForm.Subject + "1", returnedForm.Subject);
Assert.AreEqual(editForm.Text + "1", returnedForm.Text);
}
示例7: missTrailingSlash
public void missTrailingSlash()
{
Console.WriteLine("Before missingData - missTrailingSlash");
// working data
string id = "";
string title = "";
string parentUri = "";
DnaTestURLRequest request = new DnaTestURLRequest(testUtils_CommentsAPI.sitename);
// fixed input data
// test variant data
string postData = testUtils_CommentsAPI.makePostXml(ref id, ref title, ref parentUri);
string mimeType = "text/xml";
string url = "http://" + testUtils_CommentsAPI.server + "/dna/api/comments/CommentsService.svc/v1/site/";
HttpStatusCode expectedHttpResponse = HttpStatusCode.NotFound;
request.SetCurrentUserEditor();
try
{
request.RequestPageWithFullURL(url, postData, mimeType);
}
catch
{// Check to make sure that the page returned with the correct information
}
Assert.IsTrue(request.CurrentWebResponse.StatusCode == expectedHttpResponse,
"Expected "+expectedHttpResponse+", got " + request.CurrentWebResponse.StatusCode);
Console.WriteLine("After missingData - missTrailingSlash");
} // ends missTrailingSlash
示例8: EditPost_MissingPostId_ReturnsError
public void EditPost_MissingPostId_ReturnsError()
{
DnaTestURLRequest request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserEditor();
var xml = GetPost(request, @"editpost?skin=purexml");
Assert.IsNotNull(xml.SelectSingleNode("H2G2/ERROR"));
Assert.IsNull(xml.SelectSingleNode("H2G2/POST-EDIT-FORM"));
}
示例9: CallCommentForumList
public static string CallCommentForumList(DnaTestURLRequest request, string sitename, string contactFormID, string additionalParams)
{
string requestURL = "https://" + DnaTestURLRequest.CurrentServer + "/dna/" + sitename + "/commentsforumlist/?s_siteid=1" + additionalParams;
request.SetCurrentUserEditor();
request.AssertWebRequestFailure = false;
request.RequestSecurePage(requestURL);
return requestURL;
}
示例10: CallCommentForumList
public static string CallCommentForumList(DnaTestURLRequest request, string additionalParams)
{
string requestURL = "admin/commentsforumlist?s_siteid=1" + additionalParams;
request.SetCurrentUserEditor();
request.AssertWebRequestFailure = false;
request.RequestSecurePage(requestURL);
return requestURL;
}
示例11: CreateEditorsPickHelper
/// <summary>
/// Helper Function for Tests that require an editors pick.
/// </summary>
/// <param name="commentId"></param>
public void CreateEditorsPickHelper( String siteName, int commentId )
{
// Setup the request url
string url = String.Format("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/{0}/comments/{1}/editorpicks/", _sitename, commentId);
DnaTestURLRequest request = new DnaTestURLRequest(siteName);
request.SetCurrentUserEditor();
request.RequestPageWithFullURL(url, "No data to send", "text/xml");
}
示例12: 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
示例13: UserList_AsEditorUser_ReturnsAuthorised
public void UserList_AsEditorUser_ReturnsAuthorised()
{
var request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserEditor();
request.UseEditorAuthentication = true;
request.RequestPage("userlist?skin=purexml");
var xml = request.GetLastResponseAsXML();
CheckNoError(xml);
}
示例14: editorUser
public void editorUser()
{
Console.WriteLine("Before userTypes - editorUser");
DnaTestURLRequest request = new DnaTestURLRequest(testUtils_ratingsAPI.sitename);
request.SetCurrentUserEditor();
doIt_xml(request, HttpStatusCode.OK);
Console.WriteLine("After userTypes - editorUser");
}
示例15: TermsFilterAdminPage_WithEditorAuthenticationAsEditor_AccessDenied
public void TermsFilterAdminPage_WithEditorAuthenticationAsEditor_AccessDenied()
{
var siteName = "moderation";
var request = new DnaTestURLRequest(siteName) { UseEditorAuthentication = true };
request.SetCurrentUserEditor();
request.RequestPage("termsfilteradmin?modclassid=2&skin=purexml");
var doc = request.GetLastResponseAsXML();
Assert.AreEqual("ERROR",doc.SelectSingleNode("//H2G2").Attributes["TYPE"].Value);
Assert.IsNotNull(doc.SelectSingleNode("//H2G2/ERROR/ERRORMESSAGE"));
Assert.IsNull(doc.SelectSingleNode("//H2G2/TERMADMIN"));
}