public void TestMethodAddMultipleItems()
        {
            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 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 Song C#", "Song author", "99992223892", 
                    "http://www.introsong.info"});
            catalog.Add(song);

            Assert.AreEqual(4, catalog.Count);
        }
Пример #2
0
        public void AddMultipleItems()
        {
            Catalog contentCatalog = new Catalog();
            ContentItem book = new ContentItem(ContentType.Book,
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            contentCatalog.Add(book);

            ContentItem movie = new ContentItem(ContentType.Movie,
                new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" });
            contentCatalog.Add(movie);

            ContentItem secretBook = new ContentItem(ContentType.Book,
                new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" });
            contentCatalog.Add(secretBook);

            ContentItem song = new ContentItem(ContentType.Song,
                new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" });
            contentCatalog.Add(song);

            ContentItem application = new ContentItem(ContentType.Application,
                new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" });
            contentCatalog.Add(application);

            Assert.AreEqual(5, contentCatalog.Count);
        }
Пример #3
0
        public void AddSingleItemTest()
        {
            Catalog contentCatalog = new Catalog();
            ContentItem item = new ContentItem(ContentType.Book,
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            contentCatalog.Add(item);

            Assert.AreEqual(1, contentCatalog.Count);
        }
        public void TestMethodAddOneItem()
        {
            Catalog catalog = new Catalog();
            ContentItem item1 = new ContentItem(
                ContentType.Book,
                new string[] {"Intro C#", "S.Nakov", "12763892", 
                    "http://www.introprogramming.info"
                });
            catalog.Add(item1);

            Assert.AreEqual(1, catalog.Count);
        }
Пример #5
0
        public void Add5000Items()
        {
            Catalog contentCatalog = new Catalog();
            for (int i = 0; i < 5000; i++)
            {
                ContentItem item = new ContentItem(ContentType.Book,
                new string[] { "Intro C#" + i, "S.Nakov", "12763892", "http://www.introprogramming.info" });
                contentCatalog.Add(item);
            }

            Assert.AreEqual(5000, contentCatalog.Count);
        }
        public void TestMethodGetListContentOneItem()
        {
            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("Intro C#", 10);
            Assert.AreEqual(1, 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);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public void UpdateSingleItemTest()
        {
            Catalog contentCatalog = new Catalog();
            ContentItem movie = new ContentItem(ContentType.Movie,
                new string[] { "Intro C#", "Author", "12345", "http://www.intromovie.info" });
            contentCatalog.Add(movie);

            var result = contentCatalog.UpdateContent("http://www.intromovie.info", "http://test.com");

            Assert.AreEqual(1, result);
        }
Пример #12
0
        public void UpdateMultipleItems()
        {
            Catalog contentCatalog = new Catalog();
            ContentItem movie = new ContentItem(ContentType.Movie,
                new string[] { "Intro C#", "Movie", "12345", "http://www.intromovie.info" });
            contentCatalog.Add(movie);

            ContentItem book = new ContentItem(ContentType.Book,
                new string[] { "Intro C#", "Book", "123456", "http://www.blahblah.com" });
            contentCatalog.Add(book);

            ContentItem app = new ContentItem(ContentType.Application,
                new string[] { "Intro C#", "Application", "123457", "http://www.intromovie.info" });
            contentCatalog.Add(app);

            ContentItem song = new ContentItem(ContentType.Song,
                new string[] { "Intro C#", "Song", "1234578", "http://www.intromovie.info" });
            contentCatalog.Add(song);

            ContentItem otherBook = new ContentItem(ContentType.Book,
                new string[] { "Other Intro C#", "Other Book", "12345789", "http://www.noURL.info" });
            contentCatalog.Add(otherBook);

            ContentItem otherSong = new ContentItem(ContentType.Song,
                new string[] { "Other Song C#", "Other Song", "123457899", "http://www.intromovie.info" });
            contentCatalog.Add(otherSong);

            var result = contentCatalog.UpdateContent("http://www.intromovie.info", "http://test.com");

            Assert.AreEqual(4, result);
        }
Пример #13
0
        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());
        }
Пример #14
0
        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());
        }
Пример #15
0
        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());
        }