public void SerializeTest()
        {
            Catalog catalog = new Catalog
            {
                Books = new List <Book>
                {
                    new Book()
                    {
                        Author = new Author()
                        {
                            Name = "Test Author Name 1"
                        },
                        CreatedDate = DateTime.Now,
                        Genre       = Genres.Computer,
                        Description =
                            "COM &amp; .NET Component Services provides both traditional COM programmers and new .NET component developers",
                        Id          = 1,
                        PublishDate = DateTime.Now,
                        Title       = "COM and .NET Component Services",
                        Publisher   = "O'Reilly"
                    },
                    new Book()
                    {
                        Author = new Author()
                        {
                            Name = "Corets, Eva"
                        },
                        CreatedDate = DateTime.Now,
                        Genre       = Genres.Fantasy,
                        Description =
                            "After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society",
                        Id          = 2,
                        PublishDate = DateTime.Now,
                        Title       = "Maeve Ascendant",
                        Publisher   = "R &amp; D"
                    },
                    new Book()
                    {
                        Author = new Author()
                        {
                            Name = "Corets, Eva"
                        },
                        CreatedDate = DateTime.Now,
                        Genre       = Genres.Fantasy,
                        Description = "Sequel to Maeve",
                        Id          = 3,
                        PublishDate = DateTime.Now,
                        Title       = "Oberon's Legacy",
                        Publisher   = "R &amp; D"
                    }
                }
            };

            var serializer = new CatalogSerializer();

            serializer.Serialize(catalog, @"E:\result_1.xml");
            var result = serializer.Deserialize(@"E:\result_1.xml");

            CollectionAssert.AreEqual(result.Books, catalog.Books);
        }
Exemplo n.º 2
0
        public void SerializeTest()
        {
            var catalog = new Catalog
            {
                Date  = new DateTime(2016, 2, 5),
                Books = _books
            };

            _serializer.Serialize(catalog, "books_serialized.xml");
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            CatalogSerializer uploadCatalog = new CatalogSerializer();

            Console.WriteLine(@"Deserialize from 'books.xml'...");
            Console.WriteLine();
            Catalog catalog = uploadCatalog.Deserialize();

            ShowCatalog(catalog);

            Console.WriteLine();
            Console.WriteLine(@"Serialize to 'books.xml'...");
            uploadCatalog.Serialize(catalog);

            Console.Read();
        }
        public void CatalogIncorrectFilenameTest()
        {
            var serializer = new CatalogSerializer();

            serializer.Serialize(new Catalog(), @"K:\result_1.xml");
        }
        public void CatalogNullSerializeTest()
        {
            var serializer = new CatalogSerializer();

            serializer.Serialize(null, @"E:\result_1.xml");
        }