Exemplo n.º 1
0
        public static ServerTestData Create(Server a_server)
        {
            ServerTestData std = new ServerTestData();

            std.Name   = a_server.Name;
            std.Server = a_server;
            return(std);
        }
Exemplo n.º 2
0
        private bool Compare(ServerTestData a_from_xml, ServerTestData a_downloaded)
        {
            if (!a_from_xml.Compare(a_downloaded))
            {
                GenerateInfo(a_downloaded);
                return false;
            }

            return true;
        }
Exemplo n.º 3
0
        private bool Compare(ServerTestData a_from_xml, ServerTestData a_downloaded)
        {
            if (!a_from_xml.Compare(a_downloaded))
            {
                GenerateInfo(a_downloaded);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
 private void Check(ServerTestData a_server_test_data)
 {
     foreach (var serie_test_data in a_server_test_data.Series)
     {
         foreach (var chapter_test_data in serie_test_data.Chapters)
         {
             foreach (var page_test_data in chapter_test_data.Pages)
             {
                 Assert.IsTrue(File.Exists(page_test_data.FileName));
             }
         }
     };
 }
Exemplo n.º 5
0
 private void Check(ServerTestData a_server_test_data)
 {
     foreach (var serie_test_data in a_server_test_data.Series)
     {
         foreach (var chapter_test_data in serie_test_data.Chapters)
         {
             foreach (var page_test_data in chapter_test_data.Pages)
             {
                 Assert.IsTrue(File.Exists(page_test_data.FileName));
             }
         }
     }
     ;
 }
Exemplo n.º 6
0
        public static void GenerateInfo(ServerTestData a_server_test_data, bool a_downloaded = true)
        {
            string a_suffix = a_downloaded ? ERROR_SUFFIX : "";

            a_server_test_data.Save(TestBase.GetTestFilePath("_" + a_server_test_data.Name + a_suffix + ".xml"));

            foreach (var page in from serie in a_server_test_data.Series
                                 from chapter in serie.Chapters
                                 from page in chapter.Pages
                                 select page)
            {
                var image_name = Path.Combine(
                    Path.GetDirectoryName(page.FileName),
                    Path.GetFileNameWithoutExtension(page.FileName) + a_suffix + Path.GetExtension(page.FileName));
                page.Image.Save(image_name);
            }
        }
Exemplo n.º 7
0
        public static void GenerateInfo(ServerTestData a_server_test_data, bool a_downloaded = true)
        {
            string a_suffix = a_downloaded ? ERROR_SUFFIX : "";

            a_server_test_data.Save(TestBase.GetTestFilePath("_" + a_server_test_data.Name + a_suffix + ".xml"));

            foreach (var page in from serie in a_server_test_data.Series
                     from chapter in serie.Chapters
                     from page in chapter.Pages
                     select page)
            {
                var image_name = Path.Combine(
                    Path.GetDirectoryName(page.FileName),
                    Path.GetFileNameWithoutExtension(page.FileName) + a_suffix + Path.GetExtension(page.FileName));
                page.Image.Save(image_name);
            }
        }
Exemplo n.º 8
0
        private void TestXml(string a_server_name)
        {
            DeleteErrors(a_server_name);
            var from_xml   = ServerTestData.Load(TestBase.GetTestFilePath("_" + a_server_name + ".xml"));
            var downloaded = ServerTestData.Load(GetTestFilePath("_" + a_server_name + ".xml"));

            try
            {
                downloaded.Download();

                Assert.IsTrue(Compare(from_xml, downloaded));
                Check(from_xml);
                Check(downloaded);
            }
            catch
            {
                GenerateInfo(downloaded);
                throw;
            }
        }
Exemplo n.º 9
0
        public void _RegeneratedXmlsAndImages()
        {
            DeleteErrors("");

            var xmls = Directory.GetFiles(TestBase.GetTestDataDir(), "*.xml");

            foreach (var xml in xmls)
            {
                WriteLine(xml);

                if (!xml.Contains("Nexus"))
                {
                    continue;
                }

                var std = ServerTestData.Load(xml);

                std.Series = std.Series.OrderBy(s => s.Title).ToList();
                foreach (var serie in std.Series)
                {
                    serie.Chapters = serie.Chapters.OrderBy(ch => ch.Index).ToList();

                    foreach (var chapter in serie.Chapters)
                    {
                        chapter.Pages = chapter.Pages.OrderBy(p => p.Index).ToList();
                    }
                }

                try
                {
                    std.Download();
                }
                catch
                {
                    GenerateInfo(std);
                    throw;
                }

                GenerateInfo(std, false);
            }
        }
Exemplo n.º 10
0
        public bool Compare(ServerTestData a_downloaded)
        {
            if (a_downloaded.SerieCount != SerieCount)
            {
                return(false);
            }

            if (a_downloaded.Name != Name)
            {
                return(false);
            }

            for (int i = 0; i < Series.Count; i++)
            {
                if (!Series[i].Compare(a_downloaded.Series[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 11
0
        public static SerieTestData Load(XElement a_node, ServerTestData a_server_test_data)
        {
            SerieTestData std = new SerieTestData();

            std.ChapterCount   = Int32.Parse(a_node.Element("ChapterCount").Value);
            std.Title          = a_node.Element("Title").Value;
            std.URL            = a_node.Element("URL").Value;
            std.ServerTestData = a_server_test_data;

            Assert.IsTrue(!String.IsNullOrWhiteSpace(std.Title));
            Assert.IsTrue(!String.IsNullOrWhiteSpace(std.URL));

            if (a_node.Element("Chapters") != null)
            {
                foreach (var chapter_node in a_node.Element("Chapters").Elements())
                {
                    std.Chapters.Add(ChapterTestData.Load(chapter_node, std));
                }
            }

            return(std);
        }
Exemplo n.º 12
0
        public void _DeleteUnusedImages()
        {
            var xmls = Directory.GetFiles(TestBase.GetTestDataDir(), "*.xml");

            List <string> all_used_pages = new List <string>();

            var all_images = (from f in Directory.GetFiles(TestBase.GetTestDataDir())
                              let ext = Path.GetExtension(f).RemoveFromLeft(1).ToLower()
                                        where new string[] { "bmp", "jpg", "gif", "png" }.Contains(ext)
                              select f).ToList();

            foreach (var xml in xmls)
            {
                var std = ServerTestData.Load(xml);

                DeleteErrors(Path.GetFileNameWithoutExtension(xml));

                var pages = from serie in std.Series
                            from chapter in serie.Chapters
                            from page in chapter.Pages
                            select page;

                foreach (var page in pages)
                {
                    all_used_pages.Add(page.FileName);
                }
            }

            var unused_images = all_images.Except(all_used_pages);

            foreach (var ui in unused_images)
            {
                WriteLine("Deleting: {0}", ui);
                File.Delete(ui);
            }

            Assert.IsTrue(!unused_images.Any());
        }
Exemplo n.º 13
0
        public bool Compare(ServerTestData a_downloaded)
        {
            if (a_downloaded.SerieCount != SerieCount)
                return false;

            if (a_downloaded.Name != Name)
                return false;

            for (int i = 0; i < Series.Count; i++)
            {
                if (!Series[i].Compare(a_downloaded.Series[i]))
                    return false;
            }

            return true;
        }
Exemplo n.º 14
0
 public static ServerTestData Create(Server a_server)
 {
     ServerTestData std = new ServerTestData();
     std.Name = a_server.Name;
     std.Server = a_server;
     return std;
 }
Exemplo n.º 15
0
        public static SerieTestData Load(XElement a_node, ServerTestData a_server_test_data)
        {
            SerieTestData std = new SerieTestData();

            std.ChapterCount = Int32.Parse(a_node.Element("ChapterCount").Value);
            std.Title = a_node.Element("Title").Value;
            std.URL = a_node.Element("URL").Value;
            std.ServerTestData = a_server_test_data;

            Assert.IsTrue(!String.IsNullOrWhiteSpace(std.Title));
            Assert.IsTrue(!String.IsNullOrWhiteSpace(std.URL));

            if (a_node.Element("Chapters") != null)
            {
                foreach (var chapter_node in a_node.Element("Chapters").Elements())
                    std.Chapters.Add(ChapterTestData.Load(chapter_node, std));
            }

            return std;
        }