本文整理匯總了C#中Tests.FullInputContext.CreateDnaDataReader方法的典型用法代碼示例。如果您正苦於以下問題:C# FullInputContext.CreateDnaDataReader方法的具體用法?C# FullInputContext.CreateDnaDataReader怎麽用?C# FullInputContext.CreateDnaDataReader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Tests.FullInputContext
的用法示例。
在下文中一共展示了FullInputContext.CreateDnaDataReader方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Setup
public void Setup()
{
SnapshotInitialisation.RestoreFromSnapshot();
using (FullInputContext _context = new FullInputContext(""))
{
using (IDnaDataReader dataReader = _context.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY("update threadentries set hidden=null where entryid=" + _postId.ToString());
}
}
}
示例2: clearFromDB
/// <summary>
/// Remove all the groups from the user given in the parameter
/// </summary>
/// <param name="testUserReq">the user to be affected</param>
private void clearFromDB(DnaTestURLRequest testUserReq)
{
using (FullInputContext inputcontext = new FullInputContext(true))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
ISiteList _siteList = SiteList.GetSiteList();
ISite site = _siteList.GetSite(testUtils_CommentsAPI.sitename);
string sqlStr = "delete from GroupMembers where UserId=" + testUserReq.CurrentUserID;
reader.ExecuteDEBUGONLY(sqlStr);
sqlStr = "select * from GroupMembers where UserId=" + testUserReq.CurrentUserID;
reader.ExecuteDEBUGONLY(sqlStr);
Assert.IsFalse(reader.HasRows, "Error clearing the databse. The user whoulc have no rows in the groupMembers table");
}
}
}
示例3: StartUp
public void StartUp()
{
SnapshotInitialisation.RestoreFromSnapshot();
Statistics.InitialiseIfEmpty(null,false);
Statistics.ResetCounters();
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{//force processpremod out...
reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=1 and Name='ProcessPreMod'");
}
_siteList = SiteList.GetSiteList();
site = _siteList.GetSite("h2g2");
_comments = new Comments(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
var bannedEmails = new BannedEmails(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here
var userGroups = new UserGroups(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here
var profanityFilter = new ProfanityFilter(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);//no sending signals from here
}
}
示例4: makeClassLifo
/// <summary>
/// going directly not the database, set the flag
/// </summary>
/// <param name="up">boolean to say which way to set the flag</param>
/// <param name="modClassOfSite">needed so that we change the right thing</param>
private void makeClassLifo(Boolean flag, int modClassOfSite)
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
string sqlStr;
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
ISiteList _siteList = SiteList.GetSiteList();
ISite site = _siteList.GetSite(testUtils_CommentsAPI.sitename);
sqlStr = "UPDATE ModerationClass SET ItemRetrievalType=" + (flag ? 1 : 0);
sqlStr += " WHERE ModClassID=" + modClassOfSite;
reader.ExecuteDEBUGONLY(sqlStr);
Assert.AreEqual(reader.RecordsAffected, 1, "SQL change should have afected 1 line. Actually did " + reader.RecordsAffected);
SendSignal();
}
}
}
示例5: AddNotAllowURLsonH2G2SiteOption
/// <summary>
///
/// </summary>
/// <param name="value"></param>
private void AddNotAllowURLsonH2G2SiteOption()
{
//set max char option
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
var sql = String.Format("select * from siteoptions where siteid={0} and name='IsURLFiltered' and Value=1", 1);
reader.ExecuteDEBUGONLY(sql);
if (reader.HasRows)
{
return;
}
else
{
sql = String.Format("select * from siteoptions where siteid={0} and name='IsURLFiltered' and Value=0", 1);
reader.ExecuteDEBUGONLY(sql);
if (reader.HasRows)
{
sql = String.Format("update siteoptions set Value=1 where siteid={0} and name='IsURLFiltered'", 1);
reader.ExecuteDEBUGONLY(sql);
}
else
{
sql = String.Format("insert into siteoptions values ('General', 1, 'IsURLFiltered', 1, 1, 'Turns on and off allow URL in articles functionality')");
reader.ExecuteDEBUGONLY(sql);
}
}
}
}
DnaTestURLRequest myRequest = new DnaTestURLRequest(_sitename);
myRequest.RequestPageWithFullURL("http://" + _server + "/dna/api/comments/CommentsService.svc/V1/site/h2g2/?action=recache-site&siteid=1", "", "text/xml");
}
示例6: AlterSubEditorForArticle
private void AlterSubEditorForArticle(int userId, int h2g2Id)
{
int entryId = h2g2Id / 10;
//set max char option
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
var sql = String.Format("update acceptedrecommendations set SubEditorID={0} where entryID={1}",userId, entryId );
reader.ExecuteDEBUGONLY(sql);
}
}
}
示例7: CommentForum_ComplaintHideComment
public void CommentForum_ComplaintHideComment()
{
CommentForum commentForum = new CommentForum
{
Id = Guid.NewGuid().ToString(),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum result = CreateForum(commentForum);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
Assert.IsTrue(result.commentSummary.Total == 0);
//add a comment
CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };
CreateComment(comment, result);
//get forum again
result = ReadForum(result.Id);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
Assert.IsTrue(result.commentSummary.Total == 1);
// Now ste the closing date of the forum to something in the past.
using (FullInputContext _context = new FullInputContext(true))
{
using (IDnaDataReader dataReader = _context.CreateDnaDataReader("hidepost"))
{
dataReader.AddParameter("postid", result.commentList.comments[0].ID);
dataReader.AddParameter("hiddenid", 6);
dataReader.Execute();
}
}
result = ReadForum(result.Id);
Assert.IsTrue(result != null);
Assert.IsTrue(result.commentList.comments[0].text == "This post has been removed.", "Comment not hidden!");
Assert.IsTrue(result.commentList.comments[0].hidden == CommentStatus.Hidden.Removed_EditorComplaintTakedown);
}
示例8: SetSiteOption
/// <summary>
///
/// </summary>
/// <param name="value"></param>
public static void SetSiteOption(string server, string urlname, string section, string name, int type, string value)
{
//set max char option
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
reader.ExecuteDEBUGONLY(string.Format(
@" declare @siteid int
select @siteid=siteid from sites where urlname = '{0}';
delete siteoptions where [email protected] and section='{1}' and name='{2}';
insert into siteoptions (SiteID,Section,Name,Value,Type, Description) values(@siteid,'{1}', '{2}','{3}',{4},'test option')
", urlname, section, name, value, type));
}
}
DnaTestURLRequest myRequest = new DnaTestURLRequest(urlname);
myRequest.RequestPageWithFullURL("http://" + server + "/dna/api/comments/CommentsService.svc/V1/site/h2g2/?action=recache-site", "", "text/xml");
Thread.Sleep(2000);
}
示例9: readTable
/*
/// <summary>
/// Get the ceiling value for a review forum.
/// Crashes if it fails
/// </summary>
/// <param name="testForumId">forum to be affected</param>
/// <param name="forumCeiling">new value to be used by this forum</param>
public static string readTable(string tableName)
{
string row = "";
bool ftt = true;
IInputContext context = DnaMockery.CreateDatabaseInputContext();
using (IDnaDataReader reader = context.CreateDnaDataReader(""))
{
reader.ExecuteDEBUGONLY("SELECT * from " + tableName);
while (reader.Read())
{
if (ftt)
{
for (int i = 0; i < reader.FieldCount; i++)
{
row += reader.GetName(i) + "\t";
}
row += "\n";
ftt = false;
}
for (int i = 0; i < reader.FieldCount; i++)
{
row += reader.GetValue(i) + "\t";
}
row += "\n";
}
}
return row;
}
*/
/// <summary>
/// After a review form has been created, this will change the ceiling for the forum.
/// Crashes if it fails
/// </summary>
/// <param name="testForumId">forum to be affected</param>
/// <param name="forumCeiling">new value to be used by this forum</param>
internal static void setCeiling(string testForumId, string forumCeiling)
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
string sqlStr;
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
ISiteList _siteList = SiteList.GetSiteList();
ISite site = _siteList.GetSite(sitename);
sqlStr = "delete from siteoptions where siteid=" + site.SiteID.ToString() + " and Name='MaxForumRatingScore' ";
sqlStr += "insert into siteoptions (SiteID,Section,Name,Value,Type, Description) values(";
sqlStr += site.SiteID.ToString() + ",'CommentForum', 'MaxForumRatingScore'," + forumCeiling + ",0,'test MaxForumRatingScore value')";
reader.ExecuteDEBUGONLY(sqlStr);
// having changedd the value in the database, the cache must be updated too
// a call to any valid URL with the _ns=1 param should cause a refresh of the site cache
DnaTestURLRequest myRequest = new DnaTestURLRequest(sitename);
myRequest.RequestPageWithFullURL("http://" + server + "/dna/api/comments/CommentsService.svc/V1/site/h2g2/?action=recache-site", "", "text/xml");
}
}
}
示例10: SetMinCharLimit
private void SetMinCharLimit(int minLimit)
{
//set min and max char option
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
reader.ExecuteDEBUGONLY("insert into siteoptions (SiteID,Section,Name,Value,Type, Description) values(" + site.SiteID.ToString() + ",'CommentForum', 'MinCommentCharacterLength','" + minLimit.ToString() + "',0,'test MinCommentCharacterLength value')");
_siteList.ReInitialise();
_ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
}
}
}
示例11: DeleteMinMaxLimitSiteOptions
private void DeleteMinMaxLimitSiteOptions()
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
{
try
{
reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='MaxCommentCharacterLength'");
}
catch
{
}
try
{
reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='MinCommentCharacterLength'");
}
catch
{
}
}
_siteList.ReInitialise();
_ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
}
}
示例12: CommentForum_ComplaintHideComment
public void CommentForum_ComplaintHideComment()
{
CommentForum commentForum = new CommentForum
{
Id = Guid.NewGuid().ToString(),
ParentUri = "http://www.bbc.co.uk/dna/h2g2/",
Title = "testCommentForum"
};
CommentForum result = _comments.CreateCommentForum(commentForum, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
Assert.IsTrue(result.commentSummary.Total == 0);
//add a comment
CommentInfo comment = new CommentInfo { text = "this is a nunit generated comment." + Guid.NewGuid().ToString() };
//normal user
_comments.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList);
_comments.CallingUser.IsUserSignedInSecure(TestUserAccounts.GetNormalUserAccount.Cookie, TestUserAccounts.GetNormalUserAccount.SecureCookie, site.IdentityPolicy, site.SiteID, null, Guid.Empty);
_comments.CreateComment(result, comment);
//get forum again
result = _comments.GetCommentForumByUid(result.Id, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.Id == commentForum.Id);
Assert.IsTrue(result.ParentUri == commentForum.ParentUri);
Assert.IsTrue(result.Title == commentForum.Title);
Assert.IsTrue(result.commentSummary.Total == 1);
// Now ste the closing date of the forum to something in the past.
using (FullInputContext _context = new FullInputContext(""))
{
using (IDnaDataReader dataReader = _context.CreateDnaDataReader("hidepost"))
{
dataReader.AddParameter("postid", result.commentList.comments[0].ID);
dataReader.AddParameter("hiddenid", 6);
dataReader.Execute();
}
}
result = _comments.GetCommentForumByUid(result.Id, site);
Assert.IsTrue(result != null);
Assert.IsTrue(result.commentList.comments[0].hidden == CommentStatus.Hidden.Removed_EditorComplaintTakedown);
}
示例13: SiteManager_UpdateSiteModClassInvalidLanguage_ReturnsCorrectError
public void SiteManager_UpdateSiteModClassInvalidLanguage_ReturnsCorrectError()
{
var modId = 0;
var name = "chinesestandard";
try
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader("createnewmoderationclass"))
{
dataReader.AddParameter("classname", name);
dataReader.AddParameter("description", "chinesestandard");
dataReader.AddParameter("Language", "zh");
dataReader.AddParameter("basedonclass", 1);
dataReader.Execute();
}
SendSignal();
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY("select modclassid from moderationclass where name='" + name + "'");
Assert.IsTrue(dataReader.Read());
modId = dataReader.GetInt32("modclassid");
}
}
var request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserSuperUser();
request.UseEditorAuthentication = true;
request.RequestPage("sitemanager?skin=purexml");
var xmlDoc = request.GetLastResponseAsXML();
var listData = GeneratePostData(xmlDoc, _siteId);
var originalModClassId = listData.FirstOrDefault(x => x.Key == "modclassid").Value;
var pair = listData.Remove(listData.FirstOrDefault(x => x.Key == "modclassid"));
listData.Add(new KeyValuePair<string,string>("modclassid", modId.ToString()));
request.RequestPage("sitemanager?skin=purexml&update=1", ConvertToQueue(listData));
xmlDoc = request.GetLastResponseAsXML();
ValidateError(xmlDoc, "UPDATE ERROR");
Assert.AreEqual(originalModClassId, xmlDoc.SelectSingleNode("/H2G2/SITEMANAGER/MODERATIONCLASSID").InnerText);
}
finally
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
if (modId != 0)
{
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY("delete from TermsByModClass where modclassid=" + modId.ToString());
dataReader.ExecuteDEBUGONLY("delete from moderationclass where modclassid=" + modId.ToString());
}
}
}
}
}
示例14: SiteManager_UpdateSiteModClassValidLanguage_ReturnsCorrectUpdate
public void SiteManager_UpdateSiteModClassValidLanguage_ReturnsCorrectUpdate()
{
var modId = 0;
var originalModClassId = 0;
var request = new DnaTestURLRequest(_siteName);
request.SetCurrentUserSuperUser();
request.UseEditorAuthentication = true;
request.RequestPage("sitemanager?skin=purexml");
var xmlDoc = request.GetLastResponseAsXML();
ValidateSiteManagerPage(xmlDoc);
var listData = GeneratePostData(xmlDoc, _siteId);
originalModClassId = Int32.Parse(listData.FirstOrDefault(x => x.Key == "modclassid").Value);
try
{
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY("select modclassid from moderationclass where classlanguage='en' and modclassid <> " + originalModClassId.ToString());
Assert.IsTrue(dataReader.Read());
modId = dataReader.GetInt32("modclassid");
}
}
var pair = listData.Remove(listData.FirstOrDefault(x => x.Key == "modclassid"));
listData.Add(new KeyValuePair<string, string>("modclassid", modId.ToString()));
request.RequestPage("sitemanager?skin=purexml&update=1", ConvertToQueue(listData));
xmlDoc = request.GetLastResponseAsXML();
ValidateSiteManagerPage(xmlDoc);
Assert.AreEqual(modId.ToString(), xmlDoc.SelectSingleNode("/H2G2/SITEMANAGER/MODERATIONCLASSID").InnerText);
listData = GeneratePostData(xmlDoc, _siteId);
pair = listData.Remove(listData.FirstOrDefault(x => x.Key == "modclassid"));
listData.Add(new KeyValuePair<string, string>("modclassid", originalModClassId.ToString()));
request.RequestPage("sitemanager?skin=purexml&update=1", ConvertToQueue(listData));
xmlDoc = request.GetLastResponseAsXML();
ValidateSiteManagerPage(xmlDoc);
Assert.AreEqual(originalModClassId.ToString(), xmlDoc.SelectSingleNode("/H2G2/SITEMANAGER/MODERATIONCLASSID").InnerText);
}
finally
{
}
}
示例15: CreateComment_IPbutNoBBCUID
public void CreateComment_IPbutNoBBCUID()
{
Console.WriteLine("Before CreateComment");
DnaTestURLRequest request = new DnaTestURLRequest(_sitename);
request.SetCurrentUserNormal();
//create the forum
CommentForum commentForum = 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);
string ipAddr = "123.234.111.222";
// Setup the request url
string url = String.Format("https://" + _secureserver + "/dna/api/comments/CommentsService.svc/V1/site/{0}/commentsforums/{1}/?format=JSON&clientIp={2}", _sitename, commentForum.Id, ipAddr);
// now get the response
request.RequestPageWithFullURL(url, commentForumXml, "text/xml");
Assert.AreEqual("application/json", request.CurrentWebResponse.ContentType);
using (FullInputContext inputcontext = new FullInputContext(""))
{
using (IDnaDataReader dataReader = inputcontext.CreateDnaDataReader(""))
{
dataReader.ExecuteDEBUGONLY(@"
select top 1 * from threadentries te
left join threadentriesipaddress teip on teip.entryid=te.entryid
order by te.entryid desc");
Assert.IsTrue(dataReader.Read());
Assert.AreEqual(ipAddr, dataReader.GetString("IPAddress"));
Assert.AreEqual(Guid.Empty, dataReader.GetGuid("BBCUID"),"We expect the empty GUID if an IP address is present but the BBCUID cookie is missing");
}
}
}