Exemplo n.º 1
0
        public void CatalogGetTest_RequestedOnexagMissing()
        {
            Catalog catalog = new Catalog();
            var bookCsharp = new ContentItem(ContentItemType.Book,
                new string[] { "Intro C#", "C.Nakov", "12763892", "http://www.introprogramming.info" });
            var otherbookCsharp = new ContentItem(ContentItemType.Book,
                new string[] { "Intro C#", "B.Nakov", "12763892", "http://www.introprogramming.info" });
            var bookJava = new ContentItem(ContentItemType.Book,
                new string[] { "Intro C#", "A.Nakov", "12763892", "http://www.introprogramming.info" });
            var bookPerl = new ContentItem(ContentItemType.Book,
                new string[] { "Intro Perl", "S.Nakov", "12763892", "http://www.introprogramming.info" });

            catalog.Add(bookPerl);
            catalog.Add(otherbookCsharp);
            catalog.Add(bookCsharp);
            catalog.Add(bookJava);
            var matchingElements = catalog.GetListContent("Intro C#", 3);
            Assert.AreEqual(3, matchingElements.Count());

            string[] actual =
            {
               "Book: Intro C#; A.Nakov; 12763892; http://www.introprogramming.info",
               "Book: Intro C#; B.Nakov; 12763892; http://www.introprogramming.info",
               "Book: Intro C#; C.Nakov; 12763892; http://www.introprogramming.info"
                                                                                    };
            string[] expected = new string[3];

            var i=0;
            foreach (var item  in matchingElements)
            {
                expected[i] = item.ToString();
                i++;
            }

            CollectionAssert.AreEqual(actual, expected);
        }
Exemplo n.º 2
0
        public void CatalogGetTest_RequestedOneMatchingMissing()
        {
            Catalog catalog = new Catalog();
            var bookCsharp = new ContentItem(ContentItemType.Book,
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            var bookJava = new ContentItem(ContentItemType.Book,
                new string[] { "Intro Java", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            var bookPerl = new ContentItem(ContentItemType.Book,
                new string[] { "Intro Perl", "S.Nakov", "12763892", "http://www.introprogramming.info" });

            catalog.Add(bookCsharp);
            catalog.Add(bookCsharp);
            catalog.Add(bookCsharp);
            catalog.Add(bookJava);
            catalog.Add(bookPerl);
            var matchingElements = catalog.GetListContent("Intro Javascript", 1);
            Assert.AreEqual(0, matchingElements.Count());
        }