public void TestCatalogAddMethod_When1BookAdded() { Catalog catalog = new Catalog(); string[] bookContent = { "C++", "Nakov", "874563892", "http://www.c++.info" }; catalog.Add(new Content(ContentType.Book, bookContent)); var result = catalog.GetListContent("C++", 1); Assert.AreEqual(1, result.Count()); }
public void TestCatalogAddMethod_When1BookAdded_CheckContent() { Catalog catalog = new Catalog(); string[] bookContent = { "C++", "Nakov", "874563892", "http://www.c++.info" }; Content book = new Content(ContentType.Book, bookContent); catalog.Add(book); var result = catalog.GetListContent("C++", 1); Assert.AreSame(book, result.First()); }
public void TestCatalogAddMethod_WhenMultipleItemsAdded() { Catalog catalog = new Catalog(); string[] bookContent = { "C++", "Nakov", "874563892", "http://www.c++.info" }; Content book = new Content(ContentType.Book, bookContent); catalog.Add(book); string[] movieContent = { "Black cat", "Petko P.", "121563892", "http://www.blackCat.info" }; Content movie = new Content(ContentType.Movie, movieContent); catalog.Add(movie); string[] songContent = { "Black cat", "Alex", "1563892", "http://www.alexsong.info" }; Content song = new Content(ContentType.Song, songContent); catalog.Add(song); var result = catalog.GetListContent("Black cat", 2); Assert.AreEqual(2, result.Count()); }
public void TestMethodGetListContentMissingItem() { Catalog catalog = new Catalog(); ContentItem book = new ContentItem(ContentType.Book, new string[] {"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"}); catalog.Add(book); ContentItem movie = new ContentItem(ContentType.Movie, new string[] {"Intro Movie C#", "Movie author", "127632223892", "http://www.intromovies.info"}); catalog.Add(movie); ContentItem song = new ContentItem(ContentType.Song, new string[] {"Intro Song C#", "Song author", "99992223892", "http://www.introsong.info"}); catalog.Add(song); var result = catalog.GetListContent("Missing C#", 10); Assert.AreEqual(0, result.Count()); }
public void TestMethodUpdateContentSetTwiceSameUrl() { Catalog catalog = new Catalog(); ContentItem book = new ContentItem(ContentType.Book, new string[] {"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"}); catalog.Add(book); ContentItem movie = new ContentItem(ContentType.Movie, new string[] {"Intro C#", "Movie author", "127632223892", "http://www.intromovies.info"}); catalog.Add(movie); catalog.UpdateContent("http://www.introprogramming.info", "http://www.intromovies.info"); var result = catalog.GetListContent("Intro C#", 10); Assert.AreEqual("http://www.intromovies.info", result.First().URL); Assert.AreEqual("http://www.intromovies.info", result.Skip(1).First().URL); catalog.UpdateContent("http://www.introprogramming.info", "http://www.intromovies.info"); result = catalog.GetListContent("Intro C#", 10); Assert.AreEqual("http://www.intromovies.info", result.First().URL); Assert.AreEqual("http://www.intromovies.info", result.Skip(1).First().URL); }
public void TestMethodUpdateContentMultipleItems() { Catalog catalog = new Catalog(); ContentItem book = new ContentItem(ContentType.Book, new string[] {"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"}); catalog.Add(book); ContentItem movie = new ContentItem(ContentType.Movie, new string[] {"Intro C#", "Movie author", "127632223892", "http://www.intromovies.info"}); catalog.Add(movie); ContentItem book2 = new ContentItem(ContentType.Book, new string[] {"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"}); catalog.Add(book2); ContentItem song = new ContentItem(ContentType.Song, new string[] {"Intro C#", "Song author", "99992223892", "http://www.introsong.info"}); catalog.Add(song); catalog.UpdateContent("http://www.introprogramming.info", "http://newUrl.com"); var result = catalog.GetListContent("Intro C#", 10); Assert.AreEqual("http://newUrl.com", result.First().URL); Assert.AreEqual("http://newUrl.com", result.Skip(1).First().URL); }
public void TestMethodUpdateContentOneItemNonExisitngUrl() { Catalog catalog = new Catalog(); ContentItem book = new ContentItem(ContentType.Book, new string[] {"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"}); catalog.Add(book); catalog.UpdateContent("http://nonexistingUrl.com", "http://newurel.com"); var result = catalog.GetListContent("Intro C#", 10); Assert.AreEqual("http://www.introprogramming.info", result.First().URL); }
public void TestMethodGetListContentEmptyCatalog() { Catalog catalog = new Catalog(); var result = catalog.GetListContent("Intro C#", 10); Assert.AreEqual(0, result.Count()); }
public void GetListContentCheckOrderTest() { Catalog contentCatalog = new Catalog(); ContentItem movie = new ContentItem(ContentType.Movie, new string[] { "Intro C#", "Author", "12345", "http://www.intromovie.info" }); contentCatalog.Add(movie); ContentItem book = new ContentItem(ContentType.Book, new string[] { "Intro C#", "Author", "12356", "http://www.intromovie.info" }); contentCatalog.Add(book); ContentItem song = new ContentItem(ContentType.Song, new string[] { "Intro C#", "Author", "1234567", "http://www.intromovie.info" }); contentCatalog.Add(song); ContentItem otherBook = new ContentItem(ContentType.Book, new string[] { "Intro C#", "Other Author", "12345678", "http://www.intromovie.info" }); contentCatalog.Add(otherBook); var result = contentCatalog.GetListContent("Intro C#", 10); string[] expected = { "Book: Intro C#; Author; 12356; http://www.intromovie.info", "Book: Intro C#; Other Author; 12345678; http://www.intromovie.info", "Movie: Intro C#; Author; 12345; http://www.intromovie.info", "Song: Intro C#; Author; 1234567; http://www.intromovie.info" }; string[] actual = { result.First().ToString(), result.Skip(1).First().ToString(), result.Skip(2).First().ToString(), result.Skip(3).First().ToString() }; CollectionAssert.AreEqual(expected, actual); }
public void GetListContentSingleItemTest() { Catalog contentCatalog = new Catalog(); ContentItem movie = new ContentItem(ContentType.Movie, new string[] { "Intro Movie", "Author", "123", "http://www.intromovie.info" }); contentCatalog.Add(movie); ContentItem book = new ContentItem(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" }); contentCatalog.Add(book); var result = contentCatalog.GetListContent("Intro C#", 1); Assert.AreEqual(1, result.Count()); Assert.AreSame(book, result.First()); }
public void GetListContentNoResultsTest() { Catalog contentCatalog = new Catalog(); ContentItem movie = new ContentItem(ContentType.Movie, new string[] { "Intro Movie", "Author", "123", "http://www.intromovie.info" }); contentCatalog.Add(movie); var result = contentCatalog.GetListContent("Something Different", 1); Assert.AreEqual(0, result.Count()); }
public void GetListContentMatchingItemsFirstOnlyTest() { Catalog contentCatalog = new Catalog(); ContentItem movie = new ContentItem(ContentType.Book, new string[] { "Intro C#", "Movie Author", "12345", "http://www.intromovie.info" }); contentCatalog.Add(movie); ContentItem book = new ContentItem(ContentType.Book, new string[] { "Intro C#", "Book Author", "12356", "http://www.intromovie.info" }); contentCatalog.Add(book); ContentItem song = new ContentItem(ContentType.Song, new string[] { "Intro C#", "Song Author", "1234567", "http://www.intromovie.info" }); contentCatalog.Add(song); ContentItem otherBook = new ContentItem(ContentType.Book, new string[] { "Intro C#", "Other Book Author", "12345678", "http://www.intromovie.info" }); contentCatalog.Add(otherBook); var result = contentCatalog.GetListContent("Intro C#", 1); Assert.AreEqual(1, result.Count()); Assert.AreSame(book, result.First()); }