本文整理汇总了C#中Subtext.Framework.Data.DatabaseObjectProvider.Update方法的典型用法代码示例。如果您正苦于以下问题:C# DatabaseObjectProvider.Update方法的具体用法?C# DatabaseObjectProvider.Update怎么用?C# DatabaseObjectProvider.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subtext.Framework.Data.DatabaseObjectProvider
的用法示例。
在下文中一共展示了DatabaseObjectProvider.Update方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUpdateEnclosure
public void CanUpdateEnclosure(string title, string url, string mimetype, long size, bool addToFeed,
bool showWithPost)
{
// Arrange
UnitTestHelper.SetupBlog(string.Empty);
var repository = new DatabaseObjectProvider();
Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Simone Chiaretta", "Post for testing Enclosures",
"Listen to my great podcast");
int entryId = UnitTestHelper.Create(e);
Enclosure enc = UnitTestHelper.BuildEnclosure(title, url, mimetype, entryId, size, addToFeed, showWithPost);
repository.Create(enc);
string randomStr = UnitTestHelper.GenerateUniqueString().Left(20);
enc.Url = url + randomStr;
if (!string.IsNullOrEmpty(title))
{
enc.Title = title + randomStr;
}
enc.MimeType = mimetype + randomStr;
int randomSize = new Random().Next(10, 100);
enc.Size = size + randomSize;
// Act
repository.Update(enc);
// Assert
Entry newEntry = repository.GetEntry(entryId, true, false);
UnitTestHelper.AssertEnclosures(enc, newEntry.Enclosure);
}
示例2: Update_WithInvalidEnclosure_ThrowsArgumentException
public void Update_WithInvalidEnclosure_ThrowsArgumentException()
{
// arrange
var enclosure = new Enclosure { EntryId = 0 };
var repository = new DatabaseObjectProvider();
// act, assert
Assert.IsFalse(enclosure.IsValid);
var exception = UnitTestHelper.AssertThrows<ArgumentException>(() => repository.Update(enclosure));
Assert.AreEqual(enclosure.ValidationMessage, exception.Message);
}
示例3: CanRemoveHttpEquivAndAddName
public void CanRemoveHttpEquivAndAddName()
{
var blog = UnitTestHelper.CreateBlogAndSetupContext();
var repository = new DatabaseObjectProvider();
MetaTag tag = UnitTestHelper.BuildMetaTag("Still nothing to see here.", null, "expires", blog.Id, null, DateTime.UtcNow);
repository.Create(tag);
tag.HttpEquiv = null;
tag.Name = "author";
tag.Content = "Steve-o-rino!";
repository.Update(tag);
ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]);
}
示例4: CanRemoveNameAndAddHttpEquiv
public void CanRemoveNameAndAddHttpEquiv()
{
var blog = UnitTestHelper.CreateBlogAndSetupContext();
var repository = new DatabaseObjectProvider();
MetaTag tag = UnitTestHelper.BuildMetaTag("Nothing to see here.", "description", null, blog.Id, null,
DateTime.UtcNow);
repository.Create(tag);
tag.HttpEquiv = "cache-control";
tag.Name = null;
tag.Content = "no-cache";
repository.Update(tag);
ValidateMetaTags(tag, repository.GetMetaTagsForBlog(blog, 0, 100)[0]);
}
示例5: UpdateThrowsArgumentNullExceptionForNullImage
public void UpdateThrowsArgumentNullExceptionForNullImage()
{
var repository = new DatabaseObjectProvider();
UnitTestHelper.AssertThrowsArgumentNullException(() => repository.Update(null, new byte[0]));
}
示例6: UpdateImageThrowsArgumentNullException
public void UpdateImageThrowsArgumentNullException()
{
var repository = new DatabaseObjectProvider();
UnitTestHelper.AssertThrowsArgumentNullException(() => repository.Update((Image)null));
}
示例7: CanUpdate
public void CanUpdate()
{
UnitTestHelper.SetupBlog();
var repository = new DatabaseObjectProvider();
Image image = CreateImageInstance();
Assert.GreaterEqualThan(Config.CurrentBlog.Id, 0);
Assert.AreEqual(Config.CurrentBlog.Id, image.BlogId);
int imageId = repository.Insert(image, singlePixelBytes);
Image saved = repository.GetImage(imageId, true /* activeOnly */);
Assert.AreEqual(Config.CurrentBlog.Id, saved.BlogId, "The blog id for the image does not match!");
saved.LocalDirectoryPath = Path.GetFullPath(TestDirectory);
Assert.AreEqual("Test Image", saved.Title);
saved.Title = "A Better Title";
repository.Update(saved, singlePixelBytes);
Image loaded = repository.GetImage(imageId, true /* activeOnly */);
Assert.AreEqual(Config.CurrentBlog.Id, loaded.BlogId, "The blog id for the image does not match!");
loaded.LocalDirectoryPath = Path.GetFullPath(TestDirectory);
Assert.AreEqual("A Better Title", loaded.Title, "The title was not updated");
}
示例8: CreateAndUpdateFeedbackWithExactStatus
static FeedbackItem CreateAndUpdateFeedbackWithExactStatus(Entry entry, FeedbackType type,
FeedbackStatusFlag status)
{
var repository = new DatabaseObjectProvider();
var feedback = new FeedbackItem(type);
feedback.Title = UnitTestHelper.GenerateUniqueString();
feedback.Body = UnitTestHelper.GenerateUniqueString();
feedback.EntryId = entry.Id;
feedback.Author = "TestAuthor";
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());
subtextContext.Setup(c => c.HttpContext).Returns(new HttpContextWrapper(HttpContext.Current));
var service = new CommentService(subtextContext.Object, null);
int id = service.Create(feedback, true/*runFilters*/);
feedback = repository.Get(id);
feedback.Status = status;
repository.Update(feedback);
return repository.Get(id);
}
示例9: OnlyApprovedItemsContributeToEntryFeedbackCount
public void OnlyApprovedItemsContributeToEntryFeedbackCount()
{
Entry entry = SetupBlogForCommentsAndCreateEntry();
var repository = new DatabaseObjectProvider();
int entryId = entry.Id;
CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment, FeedbackStatusFlag.Approved);
entry = UnitTestHelper.GetEntry(entryId, PostConfig.None, false);
Assert.AreEqual(1, entry.FeedBackCount, "Expected one approved feedback entry.");
FeedbackItem comment = CreateAndUpdateFeedbackWithExactStatus(entry, FeedbackType.Comment,
FeedbackStatusFlag.FlaggedAsSpam);
entry = UnitTestHelper.GetEntry(entryId, PostConfig.None, false);
Assert.AreEqual(1, entry.FeedBackCount, "Expected one approved feedback entry.");
comment.Approved = true;
repository.Update(comment);
entry = UnitTestHelper.GetEntry(entryId, PostConfig.None, false);
Assert.AreEqual(2, entry.FeedBackCount,
"After approving the second comment, expected two approved feedback entry.");
comment.Approved = false;
repository.Update(comment);
entry = UnitTestHelper.GetEntry(entryId, PostConfig.None, false);
Assert.AreEqual(1, entry.FeedBackCount,
"After un-approving the second comment, expected one approved feedback entry.");
repository.Delete(comment);
entry = UnitTestHelper.GetEntry(entryId, PostConfig.None, false);
Assert.AreEqual(1, entry.FeedBackCount,
"After un-approving the second comment, expected one approved feedback entry.");
}
示例10: CanUpdateMetaTag
public void CanUpdateMetaTag(string content, string name, string httpequiv)
{
var blog = UnitTestHelper.CreateBlogAndSetupContext();
var repository = new DatabaseObjectProvider();
MetaTag tag = UnitTestHelper.BuildMetaTag(content, name, httpequiv, blog.Id, null, DateTime.UtcNow);
repository.Create(tag);
string randomStr = UnitTestHelper.GenerateUniqueString().Left(20);
tag.Content = content + randomStr;
if (!string.IsNullOrEmpty(name))
{
tag.Name = name + randomStr;
}
if (!string.IsNullOrEmpty(httpequiv))
{
tag.HttpEquiv = httpequiv + randomStr;
}
Assert.IsTrue(repository.Update(tag));
MetaTag updTag = repository.GetMetaTagsForBlog(blog, 0, 100)[0];
ValidateMetaTags(tag, updTag);
}
示例11: Update_WithNullMetaTag_ThrowsArgumentNullException
public void Update_WithNullMetaTag_ThrowsArgumentNullException()
{
var repository = new DatabaseObjectProvider();
UnitTestHelper.AssertThrowsArgumentNullException(() => repository.Update((MetaTag)null));
}
示例12: Update_WithInvalidMetaTag_ThrowsArgumentException
public void Update_WithInvalidMetaTag_ThrowsArgumentException()
{
// arrange
var metaTag = new MetaTag(null);
var repository = new DatabaseObjectProvider();
// act, assert
Assert.IsFalse(metaTag.IsValid);
UnitTestHelper.AssertThrows<ArgumentException>(() => repository.Update(metaTag));
}