Esempio n. 1
0
        public void AddOne()
        {
            Catalog catalog = new Catalog();
            string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            CatalogEntry entry = new CatalogEntry(Content.Book, entryParams);
            catalog.Add(entry);
            IEnumerable<IContent> searchResult = catalog.GetListContent("Intro C#", 1);

            int actualCount = searchResult.Count();

            Assert.AreEqual(1, actualCount);
        }
Esempio n. 2
0
        public void AddMultipleEntries()
        {
            Catalog catalog = new Catalog();

            string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            CatalogEntry entry = new CatalogEntry(Content.Book, entryParams);
            catalog.Add(entry);

            AddSomeEntries(catalog, ref entryParams, ref entry);

            bool searchIsAccurate = true;
            IEnumerable<IContent> searchResult = catalog.GetListContent("One", 3);
            if (searchResult.Count() != 2)
            {
                searchIsAccurate = false;
            }

            searchResult = catalog.GetListContent("Angel Of Death", 3);
            if (searchResult.Count() != 1)
            {
                searchIsAccurate = false;
            }

            searchResult = catalog.GetListContent("EazFuscator.NET", 1);
            if (searchResult.Count() != 1)
            {
                searchIsAccurate = false;
            }

            searchResult = catalog.GetListContent("Intro C#", 40);
            if (searchResult.Count() != 1)
            {
                searchIsAccurate = false;
            }

            Assert.AreEqual(true, searchIsAccurate);
        }
Esempio n. 3
0
        public void GetListContent_MatchedEqualToRequested()
        {
            Catalog catalog = new Catalog();

            string commandStr = "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/";
            ICommand command = new Command(commandStr);
            ICommandExecutor executor = new CommandExecutor();

            for (int i = 0; i < 3; i++)
            {
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }

            IEnumerable<IContent> result = catalog.GetListContent("One", 3);
            Assert.AreEqual(3, result.Count());
        }
Esempio n. 4
0
        public void GetListContent_MatchedLessThanTheRequested()
        {
            string[] commandStrings = { "Add movie: One; James Wong (2001); 969763002; http://www.imdb.com/title/tt0267804/",
                                       "Add song: One; Metallica (2000); 734837437; http://sample.net",
                                       "Add application: Google Chrome; Chrome; 374837837; http://google.com"};

            Catalog catalog = new Catalog();
            ICommandExecutor executor = new CommandExecutor();

            foreach (string commandString in commandStrings)
            {
                ICommand command = new Command(commandString);
                executor.ExecuteCommand(catalog, command, new System.Text.StringBuilder());
            }

            IEnumerable<IContent> result = catalog.GetListContent("One", 6);
            Assert.AreEqual(2, result.Count());
        }
Esempio n. 5
0
 public void GetListContent_ThrowsExceptionOnNegativeElementsValue()
 {
     Catalog catalog = new Catalog();
     catalog.GetListContent("Some title", -23);
 }
Esempio n. 6
0
 public void GetListContent_ThrowsExceptionOnEmptyTitle()
 {
     Catalog catalog = new Catalog();
     catalog.GetListContent("", 2);
 }
Esempio n. 7
0
 public void GetListContent_ReturnsEmptyListOnNonExisting()
 {
     Catalog catalog = new Catalog();
     IEnumerable<IContent> result = catalog.GetListContent("some title", 5);
     Assert.AreEqual(0, result.Count());
 }
Esempio n. 8
0
        public void SearchForMoreEntries()
        {
            Catalog catalog = new Catalog();

            string[] entryParams = { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            CatalogEntry entry = new CatalogEntry(Content.Book, entryParams);
            catalog.Add(entry);

            AddSomeEntries(catalog, ref entryParams, ref entry);

            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);
            catalog.Add(entry);

            bool searchIsAccurate = false;
            IEnumerable<IContent> searchResult = catalog.GetListContent("One", 300);

            if (searchResult.Count() == 11)
            {
                searchIsAccurate = true;
            }

            Assert.AreEqual(true, searchIsAccurate);
        }