本文整理汇总了C#中NuGetGallery.Package.ApplyEdit方法的典型用法代码示例。如果您正苦于以下问题:C# Package.ApplyEdit方法的具体用法?C# Package.ApplyEdit怎么用?C# Package.ApplyEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGetGallery.Package
的用法示例。
在下文中一共展示了Package.ApplyEdit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyPackageEditUpdatesPackage
public void ApplyPackageEditUpdatesPackage()
{
var p = new Package
{
Title = "OldTitle",
Description = "OldDescription",
Summary = "OldSummary",
Tags = "OldTags",
FlattenedAuthors = "OldAuthors",
Copyright = "OldCopyright",
ReleaseNotes = "OldReleaseNotes",
Hash = "OldHash",
HashAlgorithm = "SHA512",
PackageFileSize = 0,
};
var pe = new PackageEdit
{
Title = "NewTitle",
Description = "NewDescription",
Summary = "NewSummary",
Tags = "NewTags",
Authors = "NewAuthors",
Copyright = "NewCopyright",
ReleaseNotes = "NewReleaseNotes",
};
p.PackageEdits.Add(pe);
p.ApplyEdit(pe, "SHA1024", "NewHash", 1);
Assert.Equal(1, p.PackageHistories.Count);
var h = p.PackageHistories.ElementAt(0);
Assert.Equal("OldTitle", h.Title);
Assert.Equal("OldDescription", h.Description);
Assert.Equal("OldSummary", h.Summary);
Assert.Equal("OldTags", h.Tags);
Assert.Equal("OldAuthors", h.Authors);
Assert.Equal("OldCopyright", h.Copyright);
Assert.Equal("OldReleaseNotes", h.ReleaseNotes);
Assert.Equal("SHA512", h.HashAlgorithm);
Assert.Equal("OldHash", h.Hash);
Assert.Equal(0, h.PackageFileSize);
Assert.Equal("NewTitle", p.Title);
Assert.Equal("NewDescription", p.Description);
Assert.Equal("NewSummary", p.Summary);
Assert.Equal("NewTags", p.Tags);
Assert.Equal("NewAuthors", p.FlattenedAuthors);
Assert.Equal("NewCopyright", p.Copyright);
Assert.Equal("NewReleaseNotes", p.ReleaseNotes);
Assert.Equal("SHA1024", p.HashAlgorithm);
Assert.Equal("NewHash", p.Hash);
Assert.Equal(1, p.PackageFileSize);
Assert.Equal(1, p.PackageEdits.Count); // It has to be deleted from the ObjectContext anyway so no point trying to delete it as part of ApplyEdit.
}