Beispiel #1
0
        public void LibraryManagementTest_TestAll()
        {
            var filepath = path + @"TestCatalog.xml";
            IEnumerable <ICatalogElement> Catalog = new List <ICatalogElement>()
            {
                book, paper, patent
            };

            CatalogWriter.WriteDocument(filepath, Catalog);
            IEnumerable <ICatalogElement> readCatalog = CatalogReader.readFrom(filepath);
            Book      bookResult   = null;
            Newspaper paperResult  = null;
            Patent    patentResult = null;

            foreach (var p in Catalog)
            {
                if (p is Newspaper)
                {
                    paperResult = (Newspaper)p;
                }
                if (p is Book)
                {
                    bookResult = (Book)p;
                }
                if (p is Patent)
                {
                    patentResult = (Patent)p;
                }
            }

            Assert.AreEqual(patentResult.Name.name, patent.Name.name);
            Assert.AreEqual(bookResult.ISBN, book.ISBN);
            Assert.AreEqual(paperResult.ISSN, paper.ISSN);
        }
        static void Main(string[] args)
        {
            //@"..\..\CatalogWriterExample.xml"
            //@"..\..\CatalogSample.xml"
            var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"..\..\";



            IEnumerable <ICatalogElement> catalog = CatalogReader.readFrom(path + @"CatalogSample.xml");

            foreach (var c in catalog)
            {
                Console.WriteLine(c.ToString());
            }

            Console.ReadLine();
        }
Beispiel #3
0
        public void LibraryManagementTest_TestNewspaper()
        {
            var filepath = path + @"TestNewspaper.xml";
            IEnumerable <ICatalogElement> paperCatalog = new List <ICatalogElement>()
            {
                paper
            };

            CatalogWriter.WriteDocument(filepath, paperCatalog);
            IEnumerable <ICatalogElement> readPaperCatalog = CatalogReader.readFrom(filepath);
            Newspaper result = null;

            foreach (var p in readPaperCatalog)
            {
                result = (Newspaper)p;
            }

            Assert.AreEqual(result.Name.name, paper.Name.name);
            Assert.AreEqual(result.ISSN, paper.ISSN);
        }
Beispiel #4
0
        public void LibraryManagementTest_TestBook()
        {
            var filepath = path + @"TestBook.xml";
            IEnumerable <ICatalogElement> bookCatalog = new List <ICatalogElement>()
            {
                book
            };

            CatalogWriter.WriteDocument(filepath, bookCatalog);
            IEnumerable <ICatalogElement> readBookCatalog = CatalogReader.readFrom(filepath);
            Book resultBook = null;

            foreach (var b in readBookCatalog)
            {
                resultBook = (Book)b;
            }

            Assert.AreEqual(resultBook.Title.name, book.Title.name);
            Assert.AreEqual(resultBook.ISBN, book.ISBN);
        }
Beispiel #5
0
        public void LibraryManagementTest_TestPatent()
        {
            var filepath = path + @"TestPatent.xml";
            IEnumerable <ICatalogElement> patentCatalog = new List <ICatalogElement>()
            {
                patent
            };

            CatalogWriter.WriteDocument(filepath, patentCatalog);
            IEnumerable <ICatalogElement> readPatentCatalog = CatalogReader.readFrom(filepath);
            Patent result = null;

            foreach (var p in readPatentCatalog)
            {
                result = (Patent)p;
            }

            Assert.AreEqual(result.Name.name, patent.Name.name);
            Assert.AreEqual(result.RegistrationNumber, patent.RegistrationNumber);
        }