BloomTests.Publish.ExportEpubTests.ImageStyles_ConvertedToPercent_SpecialCases C# (CSharp) Method

ImageStyles_ConvertedToPercent_SpecialCases() private method

private ImageStyles_ConvertedToPercent_SpecialCases ( ) : void
return void
        public void ImageStyles_ConvertedToPercent_SpecialCases()
        {
            // First image triggers special case for missing height
            // Second image triggers special cases for no width at all.
            var book = SetupBookLong("This is some text", "en",
                extraPageClass: " A5Portrait",
                extraImages: @"<div><img src='image1.png' width='334' height='220' style='width:334px; margin-left: 34px; margin-top: 0px;'></img></div>
                            <div><img src='image2.png' width='330' height='220' style='margin-top: 0px;'></img></div>");
            MakeImageFiles(book, "image1", "image2");
            MakeEpub("output", "ImageStyles_ConvertedToPercent_SpecialCases", book);
            CheckBasicsInManifest();
            CheckBasicsInPage();

            AssertThatXmlIn.String(_page1Data).HasAtLeastOneMatchForXpath("//xhtml:img[@style='margin-top: 0px;']", _ns);
            var marginboxInches = (297.0/2.0 - 40) / 25.4;
            var picWidthInches = 334 / 96.0;
            var widthPercent = Math.Round(picWidthInches / marginboxInches * 1000) / 10;
            var picIndentInches = 34 / 96.0;
            var picIndentPercent = Math.Round(picIndentInches / marginboxInches * 1000) / 10;
            AssertThatXmlIn.String(_page1Data).HasAtLeastOneMatchForXpath("//xhtml:img[@style='height:auto; width:" + widthPercent.ToString("F1")
                + "%; margin-left: " + picIndentPercent.ToString("F1") + "%; margin-top: 0px;']", _ns);
            AssertThatXmlIn.String(_page1Data).HasAtLeastOneMatchForXpath("//xhtml:img[@style='margin-top: 0px;']", _ns);
        }