本文整理汇总了C#中Subtext.Framework.Data.DatabaseObjectProvider.CreateBlog方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseObjectProvider.CreateBlog方法的具体用法?C# DatabaseObjectProvider.CreateBlog怎么用?C# DatabaseObjectProvider.CreateBlog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subtext.Framework.Data.DatabaseObjectProvider
的用法示例。
在下文中一共展示了DatabaseObjectProvider.CreateBlog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBlogInfoDoesNotFindBlogWithWrongSubfolderInMultiBlogSystem
public void GetBlogInfoDoesNotFindBlogWithWrongSubfolderInMultiBlogSystem()
{
var repository = new DatabaseObjectProvider();
string subfolder1 = UnitTestHelper.GenerateUniqueString();
string subfolder2 = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("title", "username", "password", hostName, subfolder1);
repository.CreateBlog("title", "username", "password", hostName, subfolder2);
Blog info = repository.GetBlog(hostName, string.Empty);
Assert.IsNull(info, "Hmm... Looks like found a blog using too generic of search criteria.");
}
示例2: GetBlogInfoFindsBlogWithUniqueHostAndSubfolder
public void GetBlogInfoFindsBlogWithUniqueHostAndSubfolder()
{
var repository = new DatabaseObjectProvider();
string subfolder1 = UnitTestHelper.GenerateUniqueString();
string subfolder2 = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("title", "username", "password", hostName, subfolder1);
repository.CreateBlog("title", "username", "password", hostName, subfolder2);
Blog info = repository.GetBlog(hostName, subfolder1);
Assert.IsNotNull(info, "Could not find the blog with the unique hostName & subfolder combination.");
Assert.AreEqual(info.Subfolder, subfolder1, "Oops! Looks like we found the wrong Blog!");
info = repository.GetBlog(hostName, subfolder2);
Assert.IsNotNull(info, "Could not find the blog with the unique hostName & subfolder combination.");
Assert.AreEqual(info.Subfolder, subfolder2, "Oops! Looks like we found the wrong Blog!");
}
示例3: CreateTrackbackSetsFeedbackTypeCorrectly
public void CreateTrackbackSetsFeedbackTypeCorrectly()
{
string hostname = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty, string.Empty);
Blog blog = repository.GetBlog(hostname, string.Empty);
BlogRequest.Current.Blog = blog;
Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("phil", "title", "body");
int parentId = UnitTestHelper.Create(entry);
var trackback = new Trackback(parentId, "title", new Uri("http://url"), "phil", "body");
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
//TODO: FIX!!!
subtextContext.Setup(c => c.Repository).Returns(repository);
subtextContext.Setup(c => c.Cache).Returns(new TestCache());
subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable());
var commentService = new CommentService(subtextContext.Object, null);
int id = commentService.Create(trackback, true/*runFilters*/);
FeedbackItem loadedTrackback = repository.Get(id);
Assert.IsNotNull(loadedTrackback, "Was not able to load trackback from storage.");
Assert.AreEqual(FeedbackType.PingTrack, loadedTrackback.FeedbackType, "Feedback should be a PingTrack");
}
示例4: TrackbackShowsUpInFeedbackList
public void TrackbackShowsUpInFeedbackList()
{
string hostname = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", hostname, "blog");
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, "blog", string.Empty);
Blog blog = repository.GetBlog(hostname, "blog");
BlogRequest.Current.Blog = blog;
Entry parentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("philsath aeuoa asoeuhtoensth",
"sntoehu title aoeuao eu",
"snaot hu aensaoehtu body");
int parentId = UnitTestHelper.Create(parentEntry);
ICollection<FeedbackItem> entries = repository.GetFeedbackForEntry(parentEntry);
Assert.AreEqual(0, entries.Count, "Did not expect any feedback yet.");
var trackback = new Trackback(parentId, "title", new Uri("http://url"), "phil", "body");
Config.CurrentBlog.DuplicateCommentsEnabled = true;
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Cache).Returns(new TestCache());
subtextContext.SetupBlog(Config.CurrentBlog);
subtextContext.SetupRepository(repository);
subtextContext.Setup(c => c.HttpContext.Items).Returns(new Hashtable());
var commentService = new CommentService(subtextContext.Object, null);
int trackbackId = commentService.Create(trackback, true/*runFilters*/);
new DatabaseObjectProvider().Approve(trackback, null);
entries = repository.GetFeedbackForEntry(parentEntry);
Assert.AreEqual(1, entries.Count, "Expected a trackback.");
Assert.AreEqual(trackbackId, entries.First().Id,
"The feedback was not the same one we expected. The IDs do not match.");
}
示例5: SettingDatePublishedUtcToNullRemovesItemFromSyndication
public void SettingDatePublishedUtcToNullRemovesItemFromSyndication()
{
//arrange
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", _hostName, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(_hostName, string.Empty);
Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Haacked", "Title Test", "Body Rocking");
UnitTestHelper.Create(entry);
Assert.IsTrue(entry.IncludeInMainSyndication,
"Failed to setup this test properly. This entry should be included in the main syndication.");
Assert.IsFalse(entry.DatePublishedUtc.IsNull(),
"Failed to setup this test properly. DateSyndicated should be null.");
//act
entry.DatePublishedUtc = NullValue.NullDateTime;
//assert
Assert.IsFalse(entry.IncludeInMainSyndication,
"Setting the DateSyndicated to a null date should have reset 'IncludeInMainSyndication'.");
//save it
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
subtextContext.Setup(c => c.Repository).Returns(repository);
UnitTestHelper.Update(entry, subtextContext.Object);
Entry savedEntry = UnitTestHelper.GetEntry(entry.Id, PostConfig.None, false);
//assert again
Assert.IsFalse(savedEntry.IncludeInMainSyndication,
"This item should still not be included in main syndication.");
}
示例6: RssHandlerHandlesDatePublishedUtcProperly
public void RssHandlerHandlesDatePublishedUtcProperly()
{
// arrange
string hostName = UnitTestHelper.GenerateUniqueHostname();
var repository = new DatabaseObjectProvider();
UnitTestHelper.SetHttpContextWithBlogRequest(hostName, "");
repository.CreateBlog("", "username", "password", hostName, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostName, string.Empty);
//Create two entries, but only include one in main syndication.
Entry entryForSyndication = UnitTestHelper.CreateEntryInstanceForSyndication("Haacked", "Title Test",
"Body Rocking");
UnitTestHelper.Create(entryForSyndication);
Entry entryTwoForSyndication = UnitTestHelper.CreateEntryInstanceForSyndication("Haacked", "Title Test 2",
"Body Rocking Pt 2");
int id = UnitTestHelper.Create(entryTwoForSyndication);
Entry entry = UnitTestHelper.GetEntry(id, PostConfig.None, false);
DateTime date = entry.DatePublishedUtc;
entry.IncludeInMainSyndication = false;
entry.Blog = new Blog() { Title = "MyTestBlog" };
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
subtextContext.Setup(c => c.Repository).Returns(repository);
UnitTestHelper.Update(entry, subtextContext.Object);
Assert.AreEqual(date, entry.DatePublishedUtc);
string rssOutput = null;
subtextContext.FakeSyndicationContext(Config.CurrentBlog, "/", s => rssOutput = s);
Mock<BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper);
urlHelper.Setup(u => u.BlogUrl()).Returns("/");
urlHelper.Setup(u => u.EntryUrl(It.IsAny<Entry>())).Returns("/whatever");
XmlNodeList itemNodes = GetRssHandlerItemNodes(subtextContext.Object, ref rssOutput);
Assert.AreEqual(1, itemNodes.Count, "expected one item node.");
Assert.AreEqual("Title Test", itemNodes[0].SelectSingleNode("title").InnerText,
"Not what we expected for the first title.");
Assert.AreEqual("Body Rocking",
itemNodes[0].SelectSingleNode("description").InnerText.Substring(0, "Body Rocking".Length),
"Not what we expected for the first body.");
//Include the second entry back in the syndication.
entry.IncludeInMainSyndication = true;
UnitTestHelper.Update(entry, subtextContext.Object);
UnitTestHelper.SetHttpContextWithBlogRequest(hostName, "", "");
BlogRequest.Current.Blog = repository.GetBlog(hostName, string.Empty);
subtextContext = new Mock<ISubtextContext>();
subtextContext.FakeSyndicationContext(Config.CurrentBlog, "/", s => rssOutput = s);
subtextContext.Setup(c => c.Repository).Returns(repository);
urlHelper = Mock.Get(subtextContext.Object.UrlHelper);
urlHelper.Setup(u => u.BlogUrl()).Returns("/");
urlHelper.Setup(u => u.EntryUrl(It.IsAny<Entry>())).Returns("/whatever");
itemNodes = GetRssHandlerItemNodes(subtextContext.Object, ref rssOutput);
Assert.AreEqual(2, itemNodes.Count, "Expected two items in the feed now.");
}
示例7: GetBlogInfoLoadsOpenIDSettings
public void GetBlogInfoLoadsOpenIDSettings()
{
var repository = new DatabaseObjectProvider();
repository.CreateBlog("title", "username", "password", hostName, string.Empty);
Blog info = repository.GetBlog(hostName, string.Empty);
info.OpenIdServer = "http://server.example.com/";
info.OpenIdDelegate = "http://delegate.example.com/";
repository.UpdateConfigData(info);
info = repository.GetBlog(hostName, string.Empty);
Assert.AreEqual("http://server.example.com/", info.OpenIdServer);
Assert.AreEqual("http://delegate.example.com/", info.OpenIdDelegate);
}
示例8: AtomWriterProducesValidFeedFromDatabase
public void AtomWriterProducesValidFeedFromDatabase()
{
string hostName = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("Test", "username", "password", hostName, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostName, "");
BlogRequest.Current.Blog = repository.GetBlog(hostName, string.Empty);
Config.CurrentBlog.Email = "[email protected]";
Config.CurrentBlog.RFC3229DeltaEncodingEnabled = false;
DateTime dateCreated = DateTime.ParseExact("2008/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime();
Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Author", "testtitle", "testbody", null, dateCreated);
UnitTestHelper.Create(entry); //persist to db.
var subtextContext = new Mock<ISubtextContext>();
string rssOutput = null;
subtextContext.FakeSyndicationContext(Config.CurrentBlog, "/", s => rssOutput = s);
subtextContext.Setup(c => c.Repository).Returns(repository);
Mock<BlogUrlHelper> urlHelper = Mock.Get(subtextContext.Object.UrlHelper);
urlHelper.Setup(u => u.BlogUrl()).Returns("/");
urlHelper.Setup(u => u.EntryUrl(It.IsAny<Entry>())).Returns("/archive/2008/01/23/testtitle.aspx");
var handler = new AtomHandler(subtextContext.Object);
handler.ProcessRequest();
HttpContext.Current.Response.Flush();
var doc = new XmlDocument();
doc.LoadXml(rssOutput);
var nsmanager = new XmlNamespaceManager(doc.NameTable);
nsmanager.AddNamespace("atom", "http://www.w3.org/2005/Atom");
XmlNodeList itemNodes = doc.SelectNodes("/atom:feed/atom:entry", nsmanager);
Assert.AreEqual(1, itemNodes.Count, "expected one entry node.");
Assert.AreEqual("testtitle", itemNodes[0].SelectSingleNode("atom:title", nsmanager).InnerText,
"Not what we expected for the title.");
string urlFormat = "http://{0}/archive/2008/01/23/{1}.aspx";
string expectedUrl = string.Format(urlFormat, hostName, "testtitle");
Assert.AreEqual(expectedUrl, itemNodes[0].SelectSingleNode("atom:id", nsmanager).InnerText,
"Not what we expected for the link.");
Assert.AreEqual(expectedUrl, itemNodes[0].SelectSingleNode("atom:link/@href", nsmanager).InnerText,
"Not what we expected for the link.");
}
示例9: CanDeleteEntry
public void CanDeleteEntry()
{
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", _hostName, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(_hostName, string.Empty);
Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Haacked", "Title Test", "Body Rocking");
UnitTestHelper.Create(entry);
Entry savedEntry = UnitTestHelper.GetEntry(entry.Id, PostConfig.None, false);
Assert.IsNotNull(savedEntry);
repository.DeleteEntry(entry.Id);
savedEntry = UnitTestHelper.GetEntry(entry.Id, PostConfig.None, false);
Assert.IsNull(savedEntry, "Entry should now be null.");
}
示例10: GetPreviousAndNextBasedOnSyndicationDateNotEntryId
public void GetPreviousAndNextBasedOnSyndicationDateNotEntryId()
{
var repository = new DatabaseObjectProvider();
string hostname = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body");
previousEntry.IsActive = false;
currentEntry.IsActive = false;
nextEntry.IsActive = false;
//Create out of order.
int currentId = UnitTestHelper.Create(currentEntry);
int nextId = UnitTestHelper.Create(nextEntry);
int previousId = UnitTestHelper.Create(previousEntry);
//Now syndicate.
previousEntry.IsActive = true;
var subtextContext = new Mock<ISubtextContext>();
subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
subtextContext.Setup(c => c.Repository).Returns(repository);
UnitTestHelper.Update(previousEntry, subtextContext.Object);
Thread.Sleep(100);
currentEntry.IsActive = true;
UnitTestHelper.Update(currentEntry, subtextContext.Object);
Thread.Sleep(100);
nextEntry.IsActive = true;
UnitTestHelper.Update(nextEntry, subtextContext.Object);
Assert.IsTrue(previousId > currentId, "Ids are out of order.");
var entries = repository.GetPreviousAndNextEntries(currentId, PostType.BlogPost);
Assert.AreEqual(2, entries.Count, "Expected both previous and next.");
//The first should be next because of descending sort.
Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
}
示例11: CanAddAndRemoveAllCategories
public void CanAddAndRemoveAllCategories()
{
string hostname = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("empty title", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty, "/");
BlogRequest.Current.Blog = new DatabaseObjectProvider().GetBlog(hostname, "");
Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication("Me", "Unit Test Entry", "Body");
int id = UnitTestHelper.Create(entry);
int categoryId = UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, "My Subtext UnitTest Category");
repository.SetEntryCategoryList(id, new[] { categoryId });
Entry loaded = UnitTestHelper.GetEntry(id, PostConfig.None, true);
Assert.AreEqual("My Subtext UnitTest Category", loaded.Categories.First(),
"Expected a category for this entry");
repository.SetEntryCategoryList(id, new int[] { });
loaded = UnitTestHelper.GetEntry(id, PostConfig.None, true);
Assert.AreEqual(0, loaded.Categories.Count, "Expected that our category would be removed.");
}
示例12: GetPreviousAndNextEntriesReturnsBoth
public void GetPreviousAndNextEntriesReturnsBoth()
{
var repository = new DatabaseObjectProvider();
string hostname = UnitTestHelper.GenerateUniqueString();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-2));
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-1));
Entry nextEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow);
int previousId = UnitTestHelper.Create(previousEntry);
Thread.Sleep(100);
int currentId = UnitTestHelper.Create(currentEntry);
Thread.Sleep(100);
int nextId = UnitTestHelper.Create(nextEntry);
var entries = repository.GetPreviousAndNextEntries(currentId,
PostType.BlogPost);
Assert.AreEqual(2, entries.Count, "Expected both previous and next.");
//The more recent one is next because of desceding sort.
Assert.AreEqual(nextId, entries.First().Id, "The next entry does not match expectations.");
Assert.AreEqual(previousId, entries.ElementAt(1).Id, "The previous entry does not match expectations.");
}
示例13: GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists
public void GetPreviousAndNextEntriesReturnsPreviousWhenNoNextExists()
{
string hostname = UnitTestHelper.GenerateUniqueString();
var repository = new DatabaseObjectProvider();
repository.CreateBlog("", "username", "password", hostname, string.Empty);
UnitTestHelper.SetHttpContextWithBlogRequest(hostname, string.Empty);
BlogRequest.Current.Blog = repository.GetBlog(hostname, string.Empty);
Entry previousEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow.AddDays(-1));
Entry currentEntry = UnitTestHelper.CreateEntryInstanceForSyndication("test", "test", "body",
UnitTestHelper.GenerateUniqueString(),
DateTime.UtcNow);
int previousId = UnitTestHelper.Create(previousEntry);
int currentId = UnitTestHelper.Create(currentEntry);
var entries = repository.GetPreviousAndNextEntries(currentId,
PostType.BlogPost);
Assert.AreEqual(1, entries.Count, "Since there is no next entry, should return only 1");
Assert.AreEqual(previousId, entries.First().Id, "The previous entry does not match expectations.");
}
示例14: SettingShowEmailAddressInRssFlagDoesntChangeOtherFlags
public void SettingShowEmailAddressInRssFlagDoesntChangeOtherFlags()
{
var repository = new DatabaseObjectProvider();
repository.CreateBlog("title", "username", "password", hostName, string.Empty);
Blog info = repository.GetBlog(hostName, string.Empty);
bool test = info.IsAggregated;
info.ShowEmailAddressInRss = false;
repository.UpdateConfigData(info);
info = repository.GetBlog(hostName, string.Empty);
Assert.AreEqual(test, info.IsAggregated);
}
示例15: UpdatingBlogCannotHideAnotherBlog
public void UpdatingBlogCannotHideAnotherBlog()
{
var repository = new DatabaseObjectProvider();
repository.CreateBlog("title", "username", "password", "www.mydomain.com", string.Empty);
Blog info = repository.GetBlog("www.mydomain.com", string.Empty);
info.Host = "mydomain.com";
info.Subfolder = "MyBlog";
repository.UpdateConfigData(info);
}