Exemplo n.º 1
0
        /// <summary>
        /// Checks the initial book setup to verify that the epub's opf file and the opds file were read
        /// and the book XHTML initialized properly.
        /// </summary>
        /// <returns>The book's data div from the initial setup.</returns>
        protected XmlElement CheckInitialBookSetup(ConvertFromEpub convert, string title, bool hasOpds = true)
        {
            Assert.That(convert._epubMetaData.Title, Is.EqualTo(title));
            if (hasOpds)
            {
                Assert.That(convert._opdsEntry, Is.Not.Null, "The opds entry file should be loaded.");
            }
            else
            {
                Assert.That(convert._opdsEntry, Is.Null, "There is no opds entry file to load.");
            }
            Assert.That(convert._templatePages.Count, Is.GreaterThan(1));
            Assert.That(convert._bloomDoc, Is.Not.Null);
            var page0 = convert._bloomDoc.SelectSingleNode("/html/body/div[contains(@class,'bloom-page')]") as XmlElement;

            Assert.That(page0, Is.Null, "There should not be any pages in the empty initial book.");
            var dataDiv0 = convert._bloomDoc.SelectSingleNode("/html/body/div[@id='bloomDataDiv']") as XmlElement;

            Assert.That(dataDiv0, Is.Not.Null, "The data div should exist in the empty initial book.");
            var titleNode0 = convert._bloomDoc.SelectSingleNode("/html/head/title") as XmlElement;

            Assert.That(titleNode0, Is.Not.Null, "The title in the header should be set even in the empty book.");
            Assert.That(titleNode0.InnerText, Is.EqualTo("Book"));
            return(dataDiv0);
        }
Exemplo n.º 2
0
        public void TestVerifyConvertOptions()
        {
            Console.WriteLine("TESTING: A message about not using --portrait and --landscape together is expected.");
            var options = new ConvertOptions()
            {
                UsePortrait  = true,
                UseLandscape = true,
                // The next two merely prevent a spurious warning if the enviroment variables are not set.
                UploadUser     = "******",
                UploadPassword = "******"
            };
            var convert = new ConvertFromEpub(options);
            //SUT
            var result = convert.VerifyOptions();

            Assert.That(result, Is.False);

            convert._options.UsePortrait  = false;
            convert._options.UseLandscape = false;
            result = convert.VerifyOptions();
            Assert.That(result, Is.True);

            convert._options.UsePortrait  = true;
            convert._options.UseLandscape = false;
            result = convert.VerifyOptions();
            Assert.That(result, Is.True);

            convert._options.UsePortrait  = false;
            convert._options.UseLandscape = true;
            result = convert.VerifyOptions();
            Assert.That(result, Is.True);
        }
Exemplo n.º 3
0
        private ConvertOptions CreateConvertOptions(XmlElement entry)
        {
            var languageName = _options.LanguageName;

            if (String.IsNullOrEmpty(_options.LanguageName))
            {
                languageName = GetLanguageFromOpdsEntry(entry);
            }
            var publisherName = GetPublisherFromOpdsEntry(entry);
            var bloomFolder   = _options.BloomFolder;

            if (String.IsNullOrWhiteSpace(bloomFolder))
            {
                bloomFolder = Path.GetDirectoryName(_options.BloomExe);
            }
            return(new ConvertOptions
            {
                Verbose = _options.Verbose,
                VeryVerbose = _options.VeryVerbose,
                ReplaceExistingBook = _options.ReplaceExistingBook,
                BloomFolder = bloomFolder,
                LanguageName = languageName,
                CollectionFolder = ConvertFromEpub.FixOutputBloomSourceFolderPath(_options.BookShelfContainer, publisherName, languageName),
                EpubFile = ComputeEpubPathFromEntryTitle(entry)
                           // TODO: add --user and --password to batch options so we can set them here?
            });
        }
Exemplo n.º 4
0
        public void TestExtractInfoFromPrathamStoryAttribution()
        {
            string author, copyright, license, originalAck;
            // SUT - "Trop de bananes"
            var okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Story Attribution: This story: Too Many Bananas is written by Rohini Nilekani. © Pratham Books, 2010. Some rights reserved. Released under CC BY 4.0 license.",
                                                                              "en", out author, out copyright, out license, out originalAck);

            Assert.That(okay, Is.True, "Extracting from story attribution for \"Trop de bananes\" succeeded");
            Assert.That(author, Is.EqualTo("Rohini Nilekani"));
            Assert.That(copyright, Is.EqualTo("© Pratham Books, 2010"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.Null, "\"Trop de bananes\" is not a translation!");

            // SUT - "Le corbeau généreux"
            okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Story Attribution: This story: The Generous Crow is translated by Divaspathy Hegde. The © for this translation lies with Pratham Books, 2004. Some rights reserved. Released under CC BY 4.0 license. Based on Original story: ' ಕಾಗೆ ಬಳಗವ ಕರೆಯಿತು ', by Venkatramana Gowda. © Pratham Books, 2004. Some rights reserved. Released under CC BY 4.0 license.",
                                                                          "en", out author, out copyright, out license, out originalAck);
            Assert.That(okay, Is.True, "Extracting from story attribution for \"Le corbeau généreux\" succeeded");
            Assert.That(author, Is.EqualTo("Divaspathy Hegde"));
            Assert.That(copyright, Is.EqualTo("© Pratham Books, 2004"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.EqualTo("Based on Original story: ' ಕಾಗೆ ಬಳಗವ ಕರೆಯಿತು ', by Venkatramana Gowda. © Pratham Books, 2004. Some rights reserved. Released under CC BY 4.0 license."));

            // SUT - "Fourmis affairées"
            okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Attribution de l’histoire : Cette histoire, « Les fourmis affairées » est écrite par Kanchan Bannerjee. © Pratham Books, 2015. Certains droits réservés. Publié sous licence CC BY 4.0.",
                                                                          "fr", out author, out copyright, out license, out originalAck);

            Assert.That(okay, Is.True, "Extracting from story attribution for \"Fourmis affairées\" succeeded");
            Assert.That(author, Is.EqualTo("Kanchan Bannerjee"));
            Assert.That(copyright, Is.EqualTo("© Pratham Books, 2015"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.Null, "\"Fourmis affairées\" is not a translation!");

            // SUT - "Voler haut"
            okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Attribution de l’histoire : Cette histoire, « Voler haut » est traduite par Rohini Nilekani. Le © de cette traduction appartient à Pratham Books, 2004. Certains droits réservés. Publié sous licence CC BY 4.0. Basée sur l’histoire originale : «  तरंगत तरंगत  », de Vidya Tiware. © Pratham Books, 2004. Certains droits réservés. Publié sous licence CC BY 4.0.",
                                                                          "fr", out author, out copyright, out license, out originalAck);
            Assert.That(okay, Is.True, "Extracting from story attribution for \"Voler haut\" succeeded");
            Assert.That(author, Is.EqualTo("Rohini Nilekani"));
            Assert.That(copyright, Is.EqualTo("© Pratham Books, 2004"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.EqualTo("Basée sur l’histoire originale : «  तरंगत तरंगत  », de Vidya Tiware. © Pratham Books, 2004. Certains droits réservés. Publié sous licence CC BY 4.0."));

            // SUT - "L’heure du bain pour Chunnu et Munnu"
            okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Attribution de l’histoire\u00a0: Cette histoire, «\u00a0L’heure du bain pour Chunnu et Munnu\u00a0» est traduite par Rohini Nilekani. Le © de cette traduction appartient à Pratham Books, 2015. Certains droits réservés. Publié sous licence CC\u00a0BY\u00a04.0. Inspiré de l’histoire originale\u00a0: «\u00a0 चुन्नु-मुन्नु का नहाना \u00a0», de Rohini Nilekani. © Storyweaver, Pratham Books, 2015. Certains droits réservés. Publié sous licence CC\u00a0BY\u00a04.0.",
                                                                          "fr", out author, out copyright, out license, out originalAck);
            Assert.That(okay, Is.True, "Extracting from story attribution for \"Voler haut\" succeeded");
            Assert.That(author, Is.EqualTo("Rohini Nilekani"));
            Assert.That(copyright, Is.EqualTo("© Pratham Books, 2015"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.EqualTo("Inspiré de l’histoire originale\u00a0: «\u00a0 चुन्नु-मुन्नु का नहाना \u00a0», de Rohini Nilekani. © Storyweaver, Pratham Books, 2015. Certains droits réservés. Publié sous licence CC\u00a0BY\u00a04.0."));

            // SUT - "Dogs versus Cats" (this mess really is verbatim from the epub)
            okay = ConvertFromEpub.ExtractInfoFromPrathamStoryAttribution("Story Attribution: This story:Dogs versus Catsis translated byAlisha Berger. The © for this translation lies with Room to Read, 2013. Some rights reserved. Released under CC BY 4.0 license.Based on Original story: 'Akwatiwa lokwacabanisa inja nelikati', byNomkhosi Cynthia Thabethe. © Room to Read, 2013. Some rights reserved. Released under CC BY 4.0 license.",
                                                                          "en", out author, out copyright, out license, out originalAck);
            Assert.That(okay, Is.True, "Extracting from story attribution for \"Dogs versus Cats\" succeeded");
            Assert.That(author, Is.EqualTo("Alisha Berger"));
            Assert.That(copyright, Is.EqualTo("© Room to Read, 2013"));
            Assert.That(license, Is.EqualTo("CC BY 4.0"));
            Assert.That(originalAck, Is.EqualTo("Based on Original story: 'Akwatiwa lokwacabanisa inja nelikati', byNomkhosi Cynthia Thabethe. © Room to Read, 2013. Some rights reserved. Released under CC BY 4.0 license."));
        }
Exemplo n.º 5
0
        private void ConvertBook(XmlElement entry)
        {
            var convertOptions = CreateConvertOptions(entry);
            var convert        = new ConvertFromEpub(convertOptions);

            if (convert.RunConvert() == 0)
            {
                Console.WriteLine("INFO: converting \"{0}\" apparently succeeded.", convertOptions.EpubFile);
            }
            else
            {
                Console.WriteLine("WARNING: converting \"{0}\" apparently failed.", convertOptions.EpubFile);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Check the data imported from the front cover page.
        /// </summary>
        /// <returns>The cover image element from the front cover page.</returns>
        protected XmlElement CheckCoverPageImport(ConvertFromEpub convert, XmlElement dataDiv0, string title, string imageSrc, string creditsInnerXml, out XmlElement coverImageData, string lang = "en")
        {
            var pages = convert._bloomDoc.SelectNodes("/html/body/div[contains(@class,'bloom-page')]").Cast <XmlElement>().ToList();

            Assert.That(pages, Is.Not.Null, "A page should exist after converting a cover page.  (list not null)");
            Assert.That(pages.Count, Is.EqualTo(1), "A page should exist after converting a cover page. (list has one page)");
            var dataDiv = convert._bloomDoc.SelectSingleNode("/html/body/div[@id='bloomDataDiv']");

            Assert.That(dataDiv, Is.Not.Null, "The data div should still exist after converting the cover page.");
            Assert.That(dataDiv, Is.EqualTo(dataDiv0));
            Assert.That(pages[0], Is.Not.Null, "A page should exist after converting a cover page. (page not null)");
            Assert.That(pages[0].GetAttribute("class"), Does.Contain("outsideFrontCover"));
            Assert.That(pages[0].GetAttribute("data-xmatter-page"), Is.EqualTo("frontCover"));
            var titleNode = convert._bloomDoc.SelectSingleNode("/html/head/title") as XmlElement;

            Assert.That(titleNode, Is.Not.Null, "The title in the header should be set.");
            Assert.That(titleNode.InnerText, Is.EqualTo(title));
            var titleData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='bookTitle' and @lang='{lang}']") as XmlElement;

            Assert.That(titleData, Is.Not.Null, "The bookTitle should be set in the data div.");
            Assert.That(titleData.InnerXml, Is.EqualTo($"<p>{title}</p>"));
            var titleDiv = convert._bloomDoc.SelectSingleNode($"//div[contains(@class, 'bloom-editable') and @data-book='bookTitle' and @lang='{lang}']") as XmlElement;

            Assert.That(titleDiv, Is.Not.Null, "The title should be set on the front cover page.");
            Assert.That(titleDiv.InnerXml, Is.EqualTo($"<p>{title}</p>"));
            coverImageData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='coverImage' and @lang='*']") as XmlElement;
            Assert.That(coverImageData, Is.Not.Null, "The cover image is set in the data div.");
            Assert.That(coverImageData.InnerXml, Is.EqualTo(imageSrc));
            Assert.That(coverImageData.GetAttribute("data-copyright"), Is.Empty, "Copyrights aren't set from the cover page.");
            Assert.That(coverImageData.GetAttribute("data-license"), Is.Empty, "Licenses aren't set from the cover page.");
            var coverImg = convert._bloomDoc.SelectSingleNode("//div[@class='bloom-imageContainer']/img[@data-book='coverImage']") as XmlElement;

            Assert.That(coverImg, Is.Not.Null, "The cover image should be set on the front cover page.");
            Assert.That(coverImg.GetAttribute("src"), Is.EqualTo(imageSrc));
            var creditsData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='smallCoverCredits' and @lang='{lang}']") as XmlElement;

            Assert.That(creditsData, Is.Not.Null, "Cover credits should be set in the data div.");
            Assert.That(creditsData.InnerXml, Is.EqualTo(creditsInnerXml));
            var creditsDiv = convert._bloomDoc.SelectSingleNode($"//div[contains(@class, 'bloom-editable') and @data-book='smallCoverCredits' and @lang='{lang}']");

            Assert.That(creditsDiv, Is.Not.Null, "The credits should be inserted into the front cover page.");
            Assert.That(creditsDiv.InnerXml, Is.EqualTo(creditsInnerXml));
            return(coverImg);
        }
Exemplo n.º 7
0
        public void TestRemovePrathamCreditBoilerplate()
        {
            // SUT - "À l’intérieur du World Wide Web"
            var credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("This book was first published on StoryWeaver, Pratham Books. The development of this book has been supported by Oracle Giving Initiative.", "en");

            Assert.That(credits, Is.EqualTo("The development of this book has been supported by Oracle Giving Initiative."));

            // SUT - "Aller acheter un livre"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("This book has been published on StoryWeaver by Pratham Books. The development of the print version of this book was supported by Dubai Creek Round Table, Dubai .U.A.E. Pratham Books is a not-for-profit organization that publishes books in multiple Indian languages to promote reading among children. www.prathambooks.org", "en");
            Assert.That(credits, Is.EqualTo("The development of the print version of this book was supported by Dubai Creek Round Table, Dubai .U.A.E."));

            // SUT - "M. Anand a une aventure"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("'Mr. Anand has an Adventure' has been published on StoryWeaver by Pratham Books. It was created for #6FrameStoryChallenge, an illustration campaign organized by Pratham Books. www.prathambooks.org", "en");
            Assert.That(credits, Is.EqualTo("This book was created for #6FrameStoryChallenge, an illustration campaign organized by Pratham Books."));

            // SUT - "Trop de bananes"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("This book has been published on StoryWeaver by Pratham Books. The author of this book, Rohini Nilekani used to earlier write under the pseudonym 'Noni'. The print version of 'Too Many Bananas' has been published by Pratham Books with the support by Nikki Gulati. Pratham Books is a not-for-profit organization that publishes books in multiple Indian languages to promote reading among children. www.prathambooks.org", "en");
            Assert.That(credits, Is.EqualTo("The author of this book, Rohini Nilekani used to earlier write under the pseudonym 'Noni'. The print version of 'Too Many Bananas' has been published by Pratham Books with the support by Nikki Gulati."));

            // SUT - "Le corbeau généreux"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("This book has been published on StoryWeaver by Pratham Books. Pratham Books is a not-for-profit organization that publishes books in multiple Indian languages to promote reading among children. www.prathambooks.org", "en");
            Assert.That(credits, Is.EqualTo(""));

            // SUT - "ससा आणि कासव"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("This book has been published on StoryWeaver by Pratham Books.'The Hare and The Tortoise (Again!)' has been published by Pratham Books in partnership with the Rajiv Gandhi Foundation. Pratham Books is a not-for-profit organization that publishes books in multiple Indian languages to promote reading among children. www.prathambooks.org", "en");
            Assert.That(credits, Is.EqualTo("'The Hare and The Tortoise (Again!)' has been published by Pratham Books in partnership with the Rajiv Gandhi Foundation."));

            // SUT - "Fourmis affairées"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("Ce livre a été publié sur StoryWeaver par Pratham Books. Le développement de la version imprimée de ce livre a reçu le soutien de HDFC Asset Management Company Limited (une coentreprise avec Standard Life Investments). www.prathambooks.org ", "fr");
            Assert.That(credits, Is.EqualTo("Le développement de la version imprimée de ce livre a reçu le soutien de HDFC Asset Management Company Limited (une coentreprise avec Standard Life Investments)."));

            // SUT - "Les petits peintres"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("Ce livre a été publié sur StoryWeaver par Pratham Books. Pratham Books est un organisme à but non lucratif qui publie des livres dans plusieurs langues indiennes afin de promouvoir la lecture chez les enfants. www.prathambooks.org ", "fr");
            Assert.That(credits, Is.EqualTo(""));

            // SUT - "Se brosser n’est pas amusant !"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("«&#xa0;Se brosser n’est pas amusant&#xa0;!&#xa0;» a été publié sur StoryWeaver par Pratham Books. Le développement de ce livre a été soutenu par Fortis Charitable Foundation. www.prathambooks.org ", "fr");
            Assert.That(credits, Is.EqualTo("Le développement de ce livre a été soutenu par Fortis Charitable Foundation."));

            // SUT - "Voler haut"
            credits = ConvertFromEpub.RemovePrathamCreditBoilerplate("Ce livre a été publié sur StoryWeaver par Pratham Books. Le développement de la version imprimée de ce livre a été soutenu par Dubai Creek Round Table, Dubaï, EAU Pratham Books Pratham Books est une organisation à but non lucratif qui publie des livres dans plusieurs langues indiennes afin de promouvoir la lecture chez les enfants. www.prathambooks.org ", "fr");
            Assert.That(credits, Is.EqualTo("Le développement de la version imprimée de ce livre a été soutenu par Dubai Creek Round Table, Dubaï, EAU Pratham Books"));
        }
Exemplo n.º 8
0
        /// <summary>
        /// This method should reflect the ConvertFromEpub.Initialize() method except for the file copying
        /// and other file I/O operations.  (plus some content from ConvertBook()
        /// </summary>
        protected ConvertFromEpub InitializeForConversions(ConvertOptions opts, string opfXml, string opdsXml)
        {
            var convert = new ConvertFromEpub(opts);

            convert._epubFolder   = "/home/steve/test/epub";
            convert._epubMetaData = new EpubMetadata(convert._epubFolder, "/home/steve/test/epub/content/book.opf", opfXml);
            string langCode = convert.ForceGoodLanguageCode();

            if (String.IsNullOrWhiteSpace(opts.FileName))
            {
                convert._htmFileName = Program.SanitizeNameForFileSystem(convert._epubMetaData.Title) + ".htm";
            }
            else
            {
                convert._htmFileName = opts.FileName + ".htm";
            }

            convert._bookMetaData             = new BookMetaData();
            convert._bookMetaData.BookLineage = "056B6F11-4A6C-4942-B2BC-8861E62B03B3";
            convert._bookMetaData.Id          = Guid.NewGuid().ToString();      // This may be replaced if we're updating an existing book.

            convert._bloomDoc = new XmlDocument();
            convert._bloomDoc.PreserveWhitespace = true;
            convert._bloomDoc.LoadXml(_blankBookHtml);

            convert._templateBook = new XmlDocument();
            convert._templateBook.PreserveWhitespace = true;
            convert._templateBook.LoadXml(_pagesFileXhtml);
            convert._templatePages = convert._templateBook.SelectNodes("//div[contains(@class,'bloom-page')]").Cast <XmlElement>().ToList();
            if (opts.UseLandscape)
            {
                convert.ChangePagesToLandscape();
            }

            if (!String.IsNullOrWhiteSpace(opdsXml))
            {
                convert.LoadOpdsDataAndSetPublisher(opdsXml);
            }

            convert.SetHeadMetaAndBookLanguage();

            return(convert);
        }
Exemplo n.º 9
0
        public void TestFixInnerXml()
        {
            //SUT - "Une souris dans la maison"
            var fixedXml = ConvertFromEpub.FixInnerXml("<b> «\u00a0Où\u00a0?\u00a0» , demanda papa montant sur la fenêtre. Il baissa les rideaux. <b> «\u00a0Là\u00a0!\u00a0» , s’écria maman en sautant sur la table. Les assiettes tombèrent avec fracas. <b> </b> <br /> </b></b>");

            Assert.That(fixedXml, Is.EqualTo("<b>«\u00a0Où\u00a0?\u00a0» , demanda papa montant sur la fenêtre. Il baissa les rideaux. <b>«\u00a0Là\u00a0!\u00a0» , s’écria maman en sautant sur la table. Les assiettes tombèrent avec fracas.</b></b>"));

            //SUT - "À l’intérieur du World Wide Web"
            fixedXml = ConvertFromEpub.FixInnerXml("<b> <i> </i> </b> <i> <b> </b> </i> <i> <b> </b> </i> <b> Donc, Nettikutti, voici ce que tout le monde veut savoir\u00a0: qu’est-ce qu’Internet\u00a0? </b> <i> </i> <i> </i> <b> </b>");
            Assert.That(fixedXml, Is.EqualTo("<b>Donc, Nettikutti, voici ce que tout le monde veut savoir\u00a0: qu’est-ce qu’Internet\u00a0?</b>"));

            //SUT - "Le garçon et le tambour"
            fixedXml = ConvertFromEpub.FixInnerXml("<i>Les</i> <i>membres du chœur</i> <i>peuvent</i> <i>bouger</i> <i>leurs</i> <i>mains</i> <i>tous</i> <i> ensemble, </i> <i>pour symboliser</i> <i>la </i> <i>rivière</i> <i>qui coule. </i> <i>Le </i> <i>blanchisseur</i> <i>et</i> <i>sa</i> <i>femme</i> <i>se dégagent</i> <i>du</i> <i></i> <i>chœur, <i>en mimant</i> <i>une</i> <i>dispute. </i> <i>Leurs </i> <i>actions</i> <i>sont</i> <i>exagérées,</i> <i>mais</i> <i>on</i> <i>n’entend <i>pas</i> <i> leurs</i> <i>voix. </i> <br /> </i></i>");
            Assert.That(fixedXml, Is.EqualTo("<i>Les membres du chœur peuvent bouger leurs mains tous ensemble, pour symboliser la rivière qui coule. Le blanchisseur et sa femme se dégagent du chœur, <i>en mimant une dispute. Leurs actions sont exagérées, mais on n’entend <i>pas leurs voix.</i></i></i>"));

            //SUT - "PLONGÉE!"
            fixedXml = ConvertFromEpub.FixInnerXml("Les <b>poissons-perroquets ont des dents robustes qui forment un bec semblable à celui des perroquets, qu’ils utilisent pour racler les algues du corail dur. Certaines espèces ne se gênent pas pour manger des morceaux de corail également, et elles défèquent ensuite un sable fin qui finit sur la terre pour former de magnifiques plages de sable blanc. <br /> </b>");
            Assert.That(fixedXml, Is.EqualTo("Les <b>poissons-perroquets ont des dents robustes qui forment un bec semblable à celui des perroquets, qu’ils utilisent pour racler les algues du corail dur. Certaines espèces ne se gênent pas pour manger des morceaux de corail également, et elles défèquent ensuite un sable fin qui finit sur la terre pour former de magnifiques plages de sable blanc.</b>"));
            fixedXml = ConvertFromEpub.FixInnerXml("<b>Les poissons-clowns et les <b>anémones de mer vivent ensemble et s’entraident. Les poissons-clowns aident les anémones en nettoyant leurs tentacules et en attirant d’autres poissons pour que l’anémone les mange. Les anémones, à leur tour, permettent aux poissons-clowns de se cacher parmi leurs tentacules venimeux sans les piquer. <br /> </b></b>");
            Assert.That(fixedXml, Is.EqualTo("<b>Les poissons-clowns et les <b>anémones de mer vivent ensemble et s’entraident. Les poissons-clowns aident les anémones en nettoyant leurs tentacules et en attirant d’autres poissons pour que l’anémone les mange. Les anémones, à leur tour, permettent aux poissons-clowns de se cacher parmi leurs tentacules venimeux sans les piquer.</b></b>"));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Checks the book after any end pages have been imported.
        /// This assumes that all images have the same copyright information and that the book has a cover page and two content pages
        /// before any end pages.
        /// </summary>
        protected static void CheckTwoPageBookAfterEndPages(ConvertFromEpub convert,
                                                            XmlElement coverImg, XmlElement coverImageData, XmlElement firstPageImage, XmlElement secondPageImage,
                                                            string imageCopyright, string imageLicense, string imageCreator, string bookCopyright, string bookLicense,
                                                            string contribInnerXml, string versionAckInnerXml, string lang = "en")
        {
            var pages = convert._bloomDoc.SelectNodes("/html/body/div[contains(@class,'bloom-page')]").Cast <XmlElement>().ToList();

            Assert.That(pages.Count, Is.EqualTo(3), "Three pages should exist after converting the cover page, two content pages, and any end pages. (list has three pages)");
            CheckImageMetaData(coverImageData, imageCreator, imageCopyright, imageLicense);
            CheckImageMetaData(coverImg, imageCreator, imageCopyright, imageLicense);
            CheckImageMetaData(firstPageImage, imageCreator, imageCopyright, imageLicense);
            CheckImageMetaData(secondPageImage, imageCreator, imageCopyright, imageLicense);
            var licenseUrlData = convert._bloomDoc.SelectSingleNode("/html/body/div[@id='bloomDataDiv']/div[@data-book='licenseUrl' and @lang='*']") as XmlElement;

            Assert.That(licenseUrlData, Is.Not.Null, "End page sets licenseUrl in data div");
            Assert.That(licenseUrlData.InnerXml, Is.EqualTo(bookLicense));
            var originalContribData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='originalContributions' and @lang='{lang}']") as XmlElement;

            Assert.That(originalContribData, Is.Not.Null, "End page sets originalContributions in data div");
            Assert.That(originalContribData.InnerXml, Is.EqualTo(contribInnerXml));
            var versionAckData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='versionAcknowledgments' and @lang='{lang}']") as XmlElement;

            if (String.IsNullOrEmpty(versionAckInnerXml))
            {
                Assert.That(versionAckData, Is.Null, "We don't expect anything to be set for the versionAcknowledgements in this test.");
            }
            else
            {
                Assert.That(versionAckData, Is.Not.Null, "End page set versionAcknowledgments in data div");
                Assert.That(versionAckData.InnerXml, Is.EqualTo(versionAckInnerXml));
            }
            var copyrightData = convert._bloomDoc.SelectSingleNode("/html/body/div[@id='bloomDataDiv']/div[@data-book='copyright' and @lang='*']") as XmlElement;

            Assert.That(copyrightData, Is.Not.Null, "End page sets copyright in data div");
            Assert.That(copyrightData.InnerXml, Is.EqualTo(bookCopyright));
            var insideBackCoverData = convert._bloomDoc.SelectSingleNode($"/html/body/div[@id='bloomDataDiv']/div[@data-book='insideBackCover' and @lang='{lang}']") as XmlElement;

            Assert.That(insideBackCoverData, Is.Null, "The inside back cover in the data div should not be set during import.");
        }