Combine() public method

public Combine ( ) : string
return string
Example #1
0
        public TempLiftFile(string fileName, TemporaryFolder parentFolder, string xmlOfEntries, string claimedLiftVersion)
            : base(false)
        {
            _path = parentFolder.Combine(fileName);

            string liftContents = string.Format("<?xml version='1.0' encoding='utf-8'?><lift version='{0}'>{1}</lift>", claimedLiftVersion, xmlOfEntries);

            File.WriteAllText(_path, liftContents);
        }
Example #2
0
 public TemporaryFolder(TemporaryFolder parent, string name)
 {
     _path = parent.Combine(name);
     if (Directory.Exists(_path))
     {
         DeleteFolderThatMayBeInUse(_path);
     }
     Directory.CreateDirectory(_path);
 }
Example #3
0
        public static TempFile CreateXmlFileWithContents(string fileName, TemporaryFolder folder, string xmlBody)
        {
            string path = folder.Combine(fileName);

            using (XmlWriter x = XmlWriter.Create(path))
            {
                x.WriteStartDocument();
                x.WriteRaw(xmlBody);
            }
            return(new TempFile(path, true));
        }
        public void UpdateAllHtmlDataAttributesForAllImgElements_HasBothImgAndBackgroundImageElements_UpdatesBoth()
        {
            var dom = new HtmlDom("<html><body><img src='test.png'/><div style='color:orange; background-image=url(\"test.png\")'/></body></html>");

            using (var folder = new TemporaryFolder("bloom pictures test source"))
            {
                MakeSamplePngImageWithMetadata(folder.Combine("test.png"));
                ImageUpdater.UpdateAllHtmlDataAttributesForAllImgElements(folder.FolderPath, dom, new NullProgress());
            }

            AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-copyright='Copyright 1999 by me']", 2);
            AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-creator='joe']", 2);
            AssertThatXmlIn.Dom(dom.RawDom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-license='cc-by-nd']", 2);
        }
        private void TestUpdateImgMetadataAttributesToMatchImage(string contents)
        {
            var dom = new XmlDocument();
            dom.LoadXml(contents);

            using (var folder = new TemporaryFolder("bloom pictures test source"))
            {
                MakeSamplePngImageWithMetadata(folder.Combine("test.png"));
                ImageUpdater.UpdateImgMetdataAttributesToMatchImage(folder.FolderPath,
                    dom.SelectSingleNode("//*[@id='two']") as XmlElement, new NullProgress());
            }

            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-copyright='Copyright 1999 by me']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-creator='joe']", 1);
            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//*[@data-license='cc-by-nd']", 1);
        }
        public void UploadSmokeTest()
        {
            using(var folder = new TemporaryFolder("Upload Smoke Test"))
            {
                File.WriteAllText(folder.Combine("hello there.txt"), "hello there");
                using(var bookZip = TempFile.WithFilenameInTempFolder("Upload Smoketest.zip"))
                {
                    var zip = new BloomZipFile(bookZip.Path);
                    zip.AddDirectory(folder.FolderPath);
                    zip.Save();

                    var progress = new StringBuilderProgress();
                    ProblemBookUploader.UploadBook(BloomS3Client.UnitTestBucketName, bookZip.Path,progress);
                    Assert.IsTrue(progress.Text.Contains("Success"), progress.Text);
                }
            }
        }
Example #7
0
 public TemporaryFolder(TemporaryFolder parent, string name)
 {
     _path = parent.Combine(name);
     if (Directory.Exists(_path))
     {
        DeleteFolderThatMayBeInUse(_path);
     }
     Directory.CreateDirectory(_path);
 }
Example #8
0
        public TempLiftFile(string fileName, TemporaryFolder parentFolder, string xmlOfEntries, string claimedLiftVersion)
            : base(false)
        {
            _path = parentFolder.Combine(fileName);

            string liftContents = string.Format("<?xml version='1.0' encoding='utf-8'?><lift version='{0}'>{1}</lift>", claimedLiftVersion, xmlOfEntries);
            RobustFile.WriteAllText(_path, liftContents);
        }
        public void Setup()
        {
            _testFolder = new TemporaryFolder("hydration test");
            _bookFolder = new TemporaryFolder(_testFolder,"original name");
            _originalHtmlPath = _bookFolder.Combine("original name.html");
            File.WriteAllText(_originalHtmlPath,
                @"<html><head></head><body>
                    <div id='bloomDataDiv'>
                        <div data-book='bookTitle' lang='en'>
                                mudmen
                        </div>
                        <div data-book='topic' lang='en'>
                            Story Book
                        </div>

                        <div data-book='copyright' lang='*'>
                            Copyright © 2016, Joe Author
                        </div>

                        <div data-book='licenseUrl' lang='*'>
                            http://creativecommons.org/licenses/by/4.0/
                        </div>

                        <div data-book='originalAcknowledgments' lang='en'>
                            Some Acknowledgments
                        </div>

                        <div data-book-attributes='frontCover' data-backgroundaudio='audio/SoundTrack1.mp3' data-backgroundaudiovolume='0.17'></div>
                    </div>
                    <div id ='firstPage' class='bloom-page A5Landscape'>1st page</div>
                </body></html>");

            //NOTE: At the moment, if the bookTitle of the selected vernacular language does not match
            //the name of the file and folder, the hydration process will rename the book's folder and file,
            //just like opening it in Bloom does. At the moment, we set the name of the folder/file to be
            //the same as the title in the requested vernacular, so it isn't an issue. But further tests
            //could make it an issue. For now, these are the same:
            //_eventualHtmlPath = _testFolder.Combine("mudmen", "mudmen.htm");

            //decided that allowing a new name is just going to confuse the programs using this CLI, so
            //let's expect the program to NOT change the names for now.
            _eventualHtmlPath = _testFolder.Combine("original name", "original name.html");
        }
Example #10
0
        public void InsertPageAfter_PageRequiresStylesheetWeDontHave_StylesheetFileCopied()
        {
            //we need an actual templateBookFolder to contain the stylesheet we need to see copied into the target book
            using(var templateBookFolder = new TemporaryFolder("InsertPageAfter_PageRequiresStylesheetWeDontHave_StylesheetFileCopied"))
            {
                //just a boring simple target book
                SetDom("<div class='bloom-page' id='1'></div>", "");
                var targetBook = CreateBook();

                //our template folder will have this stylesheet file
                File.WriteAllText(templateBookFolder.Combine("foo.css"), ".dummy{width:100px}");

                //we're going to reference one stylesheet that is actually available in the template folder, and one that isn't

                var templatePage = MakeTemplatePageThatHasABookWithStylesheets( templateBookFolder, new [] {"foo.css","notthere.css"});

                targetBook.InsertPageAfter(targetBook.GetPages().First(), templatePage);

                Assert.True(File.Exists(targetBook.FolderPath.CombineForPath("foo.css")));

                //Now add it again, to see if that causes problems
                targetBook.InsertPageAfter(targetBook.GetPages().First(), templatePage);

                //Have the template list a file it doesn't actually have
                var templatePage2 = MakeTemplatePageThatHasABookWithStylesheets( templateBookFolder, new[] { "notthere.css" });

                    //for now, we just want it to not crash
                targetBook.InsertPageAfter(targetBook.GetPages().First(), templatePage2);
            }
        }
Example #11
0
 public static TempFile CreateXmlFileWithContents(string fileName, TemporaryFolder folder, string xmlBody)
 {
     string path = folder.Combine(fileName);
     using (XmlWriter x = XmlWriter.Create(path))
     {
         x.WriteStartDocument();
         x.WriteRaw(xmlBody);
     }
     return new TempFile(path, true);
 }