Esempio n. 1
0
 public void TestAddContent_WithDuplicateItem()
 {
     Catalog catalog = new Catalog();
     Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
     Content secondItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
     catalog.AddContent(firstItem);
     catalog.AddContent(secondItem);
     Assert.AreEqual(2, catalog.Count);
 }
Esempio n. 2
0
 public void TestAddContent_WithDifferentItemTypes()
 {
     Catalog catalog = new Catalog();
     Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
     Content secondItem = new Content(ContentType.Movie, new string[] { "Rocky", "Sylvester Stalone", "1353151", "http://www.rockymovie.info" });
     Content thirdItem = new Content(ContentType.Song, new string[] { "Master of puppets", "Metallica", "2342332", "http://www.metallica.info" });
     catalog.AddContent(firstItem);
     catalog.AddContent(secondItem);
     catalog.AddContent(thirdItem);
     Assert.AreEqual(3, catalog.Count);
 }
Esempio n. 3
0
        public void TestUpdatedContent_WithValidUrl()
        {
            Catalog catalog = new Catalog();
            Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            Content secondItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            Content thirdItem = new Content(ContentType.Song, new string[] { "Master of puppets", "Metallica", "2342332", "http://www.metallica.info" });
            catalog.AddContent(firstItem);
            catalog.AddContent(secondItem);
            catalog.AddContent(thirdItem);

            var result = catalog.UpdatedContent("http://www.introprogramming.info", "http://www.introprogramming.se");
            Assert.AreEqual(2, result);
        }
Esempio n. 4
0
        public void TestAddAndFindFromMultipleItems()
        {
            Catalog catalog = new Catalog();
            Content firstItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            Content secondItem = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
            Content thirdItem = new Content(ContentType.Song, new string[] { "Master of puppets", "Metallica", "2342332", "http://www.metallica.info" });
            catalog.AddContent(firstItem);
            catalog.AddContent(secondItem);
            catalog.AddContent(thirdItem);

            var contentList = catalog.GetListContent("Intro C#", 3);
            Assert.AreEqual(3, catalog.Count);
            Assert.AreEqual(2, contentList.Count());
            Assert.AreSame(contentList.ElementAt(0), firstItem);
            Assert.AreSame(contentList.ElementAt(1), secondItem);
        }
Esempio n. 5
0
 public void TestAddContent_WithSingleItem()
 {
     Catalog catalog = new Catalog();
     Content item = new Content(ContentType.Book, new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" });
     catalog.AddContent(item);
     Assert.AreEqual(1, catalog.Count);
 }
Esempio n. 6
0
 public void TestAddAndFindItem()
 {
     Catalog catalog = new Catalog();
     Content item = new Content(ContentType.Book, new string[]{"Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info"});
     catalog.AddContent(item);
     var contentList = catalog.GetListContent("Intro C#", 1);
     Assert.AreEqual(1, contentList.Count());
     Assert.AreSame(contentList.ElementAt(0), item);
 }
Esempio n. 7
0
 public void FilterPersonsByLastName_QuerySyntaxTest()
 {
     using (Catalog _newCatalog = new Catalog())
     {
         _newCatalog.AddContent(TestDataGenerator.PrepareData());
         IEnumerable <Catalog.PersonRow> _filtered = _newCatalog.Person.FilterPersonsByLastName_QuerySyntax("Person");
         Type _returnedType = _filtered.GetType();
         Assert.AreEqual <string>("System.Linq.WhereEnumerableIterator`1", $"{_returnedType.Namespace}.{_returnedType.Name}");
         Assert.AreEqual <string>("System.Linq.Enumerable+WhereEnumerableIterator`1[TP.StructuralData.LINQ_to_object.Catalog+PersonRow]", _filtered.ToString(), _filtered.ToString());
         Assert.AreEqual(2, _filtered.Count());
         foreach (Catalog.PersonRow p in _filtered)
         {
             Assert.AreEqual("Person", p.LastName);
         }
     }
 }
Esempio n. 8
0
 public void CatalogConstructorTest()
 {
     using (Catalog _newCatalog = new Catalog())
     {
         Assert.AreEqual <int>(0, _newCatalog.Person.Count);
         Assert.AreEqual <int>(0, _newCatalog.CDCatalogEntity.Count);
         Assert.AreEqual <int>(1, _newCatalog.Relations.Count);
         DataRelation _relation = _newCatalog.Relations["ArtistRelation"];
         Assert.IsNotNull(_relation);
         Assert.AreEqual <string>(_newCatalog.Person.TableName, _relation.ParentTable.TableName);
         Assert.AreEqual <string>(_newCatalog.CDCatalogEntity.TableName, _relation.ChildTable.TableName);
         _newCatalog.AddContent(TestDataGenerator.PrepareData());
         Assert.AreEqual <int>(3, _newCatalog.Person.Count);
         Assert.AreEqual <int>(15, _newCatalog.CDCatalogEntity.Count);
     }
 }