コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #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);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public static void Main()
 {
     StringBuilder output = new StringBuilder();
     ICatalog catalog = new Catalog();
     ICommandExecutor commandExecutor = new CommandExecutor();
     IList<ICommand> listOfCommands = ParseCommands();
     foreach (ICommand item in listOfCommands)
     {
         commandExecutor.ExecuteCommand(catalog, item, output);
     }
     Console.Write(output);
 }
コード例 #8
0
        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());
        }
コード例 #9
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();
            Catalog cat = new Catalog();
            ICommandExecutor c = new CommandExecutor();

            foreach (ICommand item in Parse())
            {
                c.ExecuteCommand(cat, item, output);
            }

            Console.Write(output);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: dgrigorov/TelerikAcademy-1
        public static void Main()
        {
            Catalog catalog = new Catalog();

            ICommandExecutor commandExecutor = new CommandExecutor();
            StringBuilder output = new StringBuilder();

            for (string command = null; (command = Console.ReadLine().Trim()) != "End"; )
            {
                commandExecutor.ExecuteCommand(catalog, new Command(command), output);
            }

            Console.Write(output);
        }
コード例 #11
0
        public static void Main()
        {
            StringBuilder output = new StringBuilder();

            Catalog contentCatalog = new Catalog();
            ICommandExecutor commandExecutor = new CommandExecutor();

            var commands = ReadInputCommands();
            foreach (ICommand command in commands)
            {
                commandExecutor.ExecuteCommand(contentCatalog, command, output);
            }

            Console.Write(output);
        }
コード例 #12
0
        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());
        }
コード例 #13
0
        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());
        }
コード例 #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 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());
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        public void TestMethodGetListContentEmptyCatalog()
        {
            Catalog catalog = new Catalog();

            var result = catalog.GetListContent("Intro C#", 10);
            Assert.AreEqual(0, result.Count());
        }
コード例 #20
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);
        }
コード例 #21
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());
        }
コード例 #22
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);
        }
コード例 #23
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);
        }