Add() 공개 메소드

public Add ( IContent content ) : void
content IContent
리턴 void
        public void AddDuplicateItemTest()
        {
            Catalog catalog = new Catalog();
            string[] contentItemParams =
                new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" };
            IContent contentItem = new ContentItem(ContentType.Application, contentItemParams);

            catalog.Add(contentItem);
            catalog.Add(contentItem);

            int expectedContentItems = 2;
            Assert.AreEqual(expectedContentItems, catalog.ContentItemsCount, "Invalid content items count!");
        }
        public void AddSingleAndDuplicateItemsTest()
        {
            Catalog catalog = new Catalog();
            List<string[]> contentItemParams = new List<string[]>() 
            {
                new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" },
                new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" },
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" },
                new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" }
            };
            IContent application = new ContentItem(ContentType.Application, contentItemParams[0]);
            IContent song = new ContentItem(ContentType.Song, contentItemParams[1]);
            IContent book = new ContentItem(ContentType.Book, contentItemParams[2]);
            IContent movie = new ContentItem(ContentType.Movie, contentItemParams[3]);

            catalog.Add(application);
            catalog.Add(song);
            catalog.Add(book);
            catalog.Add(book);
            catalog.Add(book);
            catalog.Add(movie);
            catalog.Add(movie);

            int expectedContentItems = 7;
            Assert.AreEqual(expectedContentItems, catalog.ContentItemsCount, "Invalid content items count!");
        }
 public void NoMatchedItemsTest()
 {
     Catalog catalog = new Catalog();
     List<string[]> contentItemParams = new List<string[]>() 
     {
         new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" },
         new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" },
         new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" },
         new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" }
     };
     IContent application = new ContentItem(ContentType.Application, contentItemParams[0]);
     IContent song = new ContentItem(ContentType.Song, contentItemParams[1]);
     IContent book = new ContentItem(ContentType.Book, contentItemParams[2]);
     IContent movie = new ContentItem(ContentType.Movie, contentItemParams[3]);
     catalog.Add(application);
     catalog.Add(song);
     catalog.Add(book);
     catalog.Add(book);
     catalog.Add(book);
     catalog.Add(movie);
     catalog.Add(movie);
     
     IEnumerable<IContent> matchedItems = catalog.GetListContent("Missing", 1);
     string[] actualTextRepresentations = GetTextRepresentationsOfMatchedItems(matchedItems);
     string[] expectedTextRepresentations = new string[] { };
     
     CollectionAssert.AreEqual(expectedTextRepresentations, actualTextRepresentations);
     Assert.AreEqual(0, matchedItems.Count());
 }
        public void UpdateUpdatedElementTest()
        {
            Catalog catalog = new Catalog();
            List<string[]> contentItemParams = new List<string[]>() 
            {
                new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" },
                new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" },
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" },
                new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" }
            };

            IContent application = new ContentItem(ContentType.Application, contentItemParams[0]);
            IContent song = new ContentItem(ContentType.Song, contentItemParams[1]);
            IContent book = new ContentItem(ContentType.Book, contentItemParams[2]);
            IContent movie = new ContentItem(ContentType.Movie, contentItemParams[3]);
            catalog.Add(application);
            catalog.Add(application);
            catalog.Add(song);
            catalog.Add(book);
            catalog.Add(book);
            catalog.Add(movie);
            catalog.Add(movie);

            int updatedItemsCount = catalog.UpdateContent("http://www.introprogramming.info", "http://newUrl.org");
            Assert.AreEqual(2, updatedItemsCount);

            updatedItemsCount = catalog.UpdateContent("http://newUrl.org", "http://www.introprogramming.info");
            Assert.AreEqual(2, updatedItemsCount);
        }
        public void UpdateNonExistingItemTest()
        {
            Catalog catalog = new Catalog();
            string[] bookParams = 
                new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
            string[] songParams =
                new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" };
            IContent book = new ContentItem(ContentType.Book, bookParams);
            IContent song = new ContentItem(ContentType.Song, songParams);
            catalog.Add(book);
            catalog.Add(song);

            int updatedItemsCount = catalog.UpdateContent("http://oldurl.org", "http://newurl.org");

            Assert.AreEqual(0, updatedItemsCount);
        }