本文整理汇总了C#中Catalog.UpdateContent方法的典型用法代码示例。如果您正苦于以下问题:C# Catalog.UpdateContent方法的具体用法?C# Catalog.UpdateContent怎么用?C# Catalog.UpdateContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Catalog
的用法示例。
在下文中一共展示了Catalog.UpdateContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateCatalog_TryToUpdateMissingUrl
public void UpdateCatalog_TryToUpdateMissingUrl()
{
string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
IContent testContent = new Content(ContentType.Book, testContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testContent);
string oldURL = "http://www.missingURL.info";
string newURL = "http://www.introprogramming.com";
int updatedItems = currentCatalog.UpdateContent(oldURL, newURL);
Assert.AreEqual(0, updatedItems);
}
示例2: UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLsCheckIsAllUpdated
public void UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLsCheckIsAllUpdated()
{
string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
IContent testContent = new Content(ContentType.Book, testContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testContent);
currentCatalog.Add(testContent);
string oldURL = "http://www.introprogramming.info";
string newURL = "http://www.introprogramming.com";
currentCatalog.UpdateContent(oldURL, newURL);
IEnumerable<IContent> currentContent = currentCatalog.GetListContent("Intro C#", 1);
bool isAllUpdated = true;
foreach (IContent content in currentContent)
{
if (oldURL == content.URL)
{
isAllUpdated = false;
break;
}
}
Assert.IsTrue(isAllUpdated);
}
示例3: UpdateCatalog_AddFiveItemsAndUpdateAll
public void UpdateCatalog_AddFiveItemsAndUpdateAll()
{
string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
IContent testContent = new Content(ContentType.Book, testContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testContent);
currentCatalog.Add(testContent);
string[] testMovieContentParams = new string[] { "IndenticalTitle", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://www.introprogramming.info" };
IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams);
currentCatalog.Add(testMovieContent);
string[] testApplicationContentParams = new string[] { "IndenticalTitle", "Mozilla", "16148072", "http://www.introprogramming.info" };
IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams);
currentCatalog.Add(testApplicationContent);
string[] testSongContentParams = new string[] { "DifferentTitle", "Metallica", "8771120", "http://www.introprogramming.info" };
IContent testSongContent = new Content(ContentType.Book, testSongContentParams);
currentCatalog.Add(testSongContent);
string oldURL = "http://www.introprogramming.info";
string newURL = "http://www.introprogramming.com";
int updatedItems = currentCatalog.UpdateContent(oldURL, newURL);
Assert.AreEqual(5, updatedItems);
}
示例4: UpdateContent_WithSingleMatchingElement_ShouldReturn1
public void UpdateContent_WithSingleMatchingElement_ShouldReturn1()
{
string oldUrl = "http://www.test0.com/";
string newUrl = "http://www.modified.com/";
ICatalog catalog = new Catalog();
for (int i = 0; i < 10; ++i)
{
catalog.Add(new Content(ContentType.Music, new string[]
{
"TestTitle", "TestMusicAuthor", "3333", @"http://www.test" + i + ".com/"
}));
}
int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl);
Assert.AreEqual(1, itemsUpdated);
}
示例5: UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLs
public void UpdateCatalog_AddTwoIndenticalBooksAndUpdateURLs()
{
string[] testContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
IContent testContent = new Content(ContentType.Book, testContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testContent);
currentCatalog.Add(testContent);
string oldURL = "http://www.introprogramming.info";
string newURL = "http://www.introprogramming.com";
currentCatalog.UpdateContent(oldURL, newURL);
IEnumerable<IContent> currentContent = currentCatalog.GetListContent("Intro C#", 1);
string currentContentNewURL = currentContent.First().URL;
Assert.AreEqual(newURL, currentContentNewURL);
}
示例6: UpdateContent_WithNoMatchingElemet
public void UpdateContent_WithNoMatchingElemet()
{
ICatalog catalog = new Catalog();
catalog.Add(new Content(ContentType.Music, new string[]
{
"TestTitle", "TestMusicAuthor", "3333", @"http://www.test1.com/"
}));
int itemsUpdated = catalog.UpdateContent("http://www.test.com/", "http://www.modified.com/");
Assert.AreEqual(0, itemsUpdated);
}
示例7: UpdateContent_WithMultipleItemsmatch_TestIfUrlsAreUpdated
public void UpdateContent_WithMultipleItemsmatch_TestIfUrlsAreUpdated()
{
string oldUrl = "http://www.test0.com/";
string newUrl = "http://www.modified.com/";
ICatalog catalog = new Catalog();
for (int i = 0; i < 10; ++i)
{
catalog.Add(new Content(ContentType.Music, new string[]
{
"TestTitle", "TestMusicAuthor", "3333", @"http://www.test" + (i % 2) + ".com/"
}));
}
int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl);
IEnumerable<IContent> updated = catalog.GetListContent("TestTitle", 1000);
bool allAreUpdated = true;
foreach (var item in updated)
{
if (item.Url == oldUrl)
{
allAreUpdated = false;
break;
}
}
Assert.IsTrue(allAreUpdated);
}
示例8: UpdateContent_WithAllElementsMatching
public void UpdateContent_WithAllElementsMatching()
{
string oldUrl = "http://www.test.com/";
string newUrl = "http://www.modified.com/";
ICatalog catalog = new Catalog();
for (int i = 0; i < 10; ++i)
{
catalog.Add(new Content(ContentType.Music, new string[]
{
"TestTitle", "TestMusicAuthor", "3333", oldUrl
}));
}
int itemsUpdated = catalog.UpdateContent(oldUrl, newUrl);
Assert.AreEqual(10, itemsUpdated);
}
示例9: TestMethodUpdateOneItem
public void TestMethodUpdateOneItem()
{
Catalog catalog = new Catalog();
Content item = new Content(ContentType.Book,
new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
catalog.Add(item);
var result = catalog.UpdateContent("http://www.introprogramming.info", "http://introprograming.info/en/");
Assert.AreEqual(result, 1);
}
示例10: TestMethodUpdateOneItem
public void TestMethodUpdateOneItem()
{
Catalog catalog = new Catalog();
ContentItem book = new ContentItem(ContentItemType.Book,
new string[] { "Intro C#", "S.Nakov", "12763892",
"http://www.introprogramming.info" });
catalog.Add(book);
ContentItem application = new ContentItem(ContentItemType.Application,
new string[] { "Intro C#", "Adam Salin", "23569842",
"http://www.app.com" });
catalog.Add(application);
ContentItem movie = new ContentItem(ContentItemType.Movie,
new string[] { "Intro C#", "James Gosling", "53265489",
"http://www.java.com" });
catalog.Add(movie);
int updatedCount = catalog.UpdateContent("http://www.java.com", "http://new.com");
Assert.AreEqual(1, updatedCount);
updatedCount = catalog.UpdateContent("http://www.java.com", "http://new.com");
Assert.AreEqual(0, updatedCount);
updatedCount = catalog.UpdateContent("http://www.app.com", "http://new.com");
Assert.AreEqual(1, updatedCount);
updatedCount = catalog.UpdateContent("http://new.com", "http://alabala.com");
Assert.AreEqual(2, updatedCount);
}