Clone() public method

public Clone ( ) : HtmlDom
return HtmlDom
        /// <summary>
        /// this one works on the dom passed to it
        /// </summary>
        /// <param name="dom"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public HtmlDom MakeDomRelocatable(HtmlDom dom, IProgress log)
        {
            var relocatableDom = dom.Clone();

            SetBaseForRelativePaths(relocatableDom, _folderPath, true);
            EnsureHasLinksToStylesheets(relocatableDom);
            UpdateStyleSheetLinkPaths(relocatableDom, _fileLocator, log);

            return(relocatableDom);
        }
        /// <summary>
        /// creates a relocatable copy of our main HtmlDom
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public HtmlDom GetRelocatableCopyOfDom(IProgress log)
        {
            HtmlDom relocatableDom = Dom.Clone();

            SetBaseForRelativePaths(relocatableDom, _folderPath, true);
            EnsureHasLinksToStylesheets(relocatableDom);
            UpdateStyleSheetLinkPaths(relocatableDom, _fileLocator, log);

            return(relocatableDom);
        }
        public virtual void Setup()
        {
            _storage = new Moq.Mock<IBookStorage>();
            _storage.Setup(x => x.GetLooksOk()).Returns(true);
            _bookDom = new HtmlDom(GetThreePageDom());
            _storage.SetupGet(x => x.Dom).Returns(() => _bookDom);
            _storage.SetupGet(x => x.Key).Returns("testkey");
            _storage.SetupGet(x => x.FileName).Returns("testTitle");
            _storage.Setup(x => x.GetRelocatableCopyOfDom(It.IsAny<IProgress>())).Returns(() =>
            {
                return
                    _bookDom.Clone();
            });// review: the real thing does more than just clone
            _storage.Setup(x => x.MakeDomRelocatable(It.IsAny<HtmlDom>(), It.IsAny<IProgress>())).Returns(
                (HtmlDom x, IProgress y) => { return x.Clone(); });// review: the real thing does more than just clone

            _storage.Setup(x => x.GetFileLocator()).Returns(() => _fileLocator.Object);

            _testFolder = new TemporaryFolder("BookTests");
            _tempFolder = new TemporaryFolder(_testFolder, "book");
            MakeSamplePngImageWithMetadata(Path.Combine(_tempFolder.Path, "original.png"));
            _storage.SetupGet(x => x.FolderPath).Returns(_tempFolder.Path);// review: the real thing does more than just clone
            _metadata = new BookInfo(_tempFolder.Path, true);
            _storage.SetupGet(x => x.MetaData).Returns(_metadata);
            _storage.Setup(x => x.HandleRetiredXMatterPacks(It.IsAny<HtmlDom>(), It.IsAny<string>()))
                .Returns((HtmlDom dom, string y) => { return y == "BigBook" ? "Factory" : y; });

            _templateFinder = new Moq.Mock<ITemplateFinder>();
            _fileLocator = new Moq.Mock<IFileLocator>();
            string root = FileLocator.GetDirectoryDistributedWithApplication(BloomFileLocator.BrowserRoot);
            string xMatter = BloomFileLocator.GetInstalledXMatterDirectory();
            _fileLocator.Setup(x => x.LocateFileWithThrow("languageDisplay.css")).Returns("../notareallocation/languageDisplay.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("previewMode.css")).Returns("../notareallocation/previewMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("origami.css")).Returns("../notareallocation/origami.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editMode.css")).Returns("../notareallocation/editMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editTranslationMode.css")).Returns("../notareallocation/editTranslationMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editOriginalMode.css")).Returns("../notareallocation/editOriginalMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editPaneGlobal.css")).Returns("../notareallocation/editPaneGlobal.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("basePage.css")).Returns("../notareallocation/basePage.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomBootstrap.js")).Returns("../notareallocation/bloomBootstrap.js");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomPreviewBootstrap.js")).Returns("../notareallocation/bloomPreviewBootstrap.js");
            _fileLocator.Setup(x => x.LocateFileWithThrow("baseEPUB.css")).Returns("../notareallocation/baseEPUB.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("customBookStyles.css")).Returns(Path.Combine(_tempFolder.Path, "customBookStyles.css"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("settingsCollectionStyles.css")).Returns(Path.Combine(_testFolder.Path, "settingsCollectionStyles.css"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("customCollectionStyles.css")).Returns(Path.Combine(_testFolder.Path, "customCollectionStyles.css"));

            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter")).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectoryWithThrow("Factory-XMatter")).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter", It.IsAny<string>())).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("Factory-XMatter".CombineForPath("Factory-XMatter.htm"))).Returns(xMatter.CombineForPath("Factory-XMatter", "Factory-XMatter.htm"));

            _fileLocator.Setup(x => x.LocateDirectory("Traditional-XMatter")).Returns(xMatter.CombineForPath("Traditional-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectoryWithThrow("Traditional-XMatter")).Returns(xMatter.CombineForPath("Traditional-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectory("Traditional-XMatter", It.IsAny<string>())).Returns(xMatter.CombineForPath("Traditional-XMatter"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("Traditional-XMatter".CombineForPath("Traditional-XMatter.htm"))).Returns(xMatter.CombineForPath("Traditional-XMatter", "Factory-XMatter.htm"));

            _fileLocator.Setup(x => x.LocateDirectory("BigBook-XMatter")).Returns(xMatter.CombineForPath("BigBook-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectoryWithThrow("BigBook-XMatter")).Returns(xMatter.CombineForPath("BigBook-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectory("BigBook-XMatter", It.IsAny<string>())).Returns(xMatter.CombineForPath("BigBook-XMatter"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("BigBook-XMatter".CombineForPath("BigBook-XMatter.htm"))).Returns(xMatter.CombineForPath("BigBook-XMatter", "BigBook-XMatter.htm"));

            //warning: we're neutering part of what the code under test is trying to do here:
            _fileLocator.Setup(x => x.CloneAndCustomize(It.IsAny<IEnumerable<string>>())).Returns(_fileLocator.Object);

            _thumbnailer = new Moq.Mock<HtmlThumbNailer>(new object[] { new NavigationIsolator() });
            _pageSelection = new Mock<PageSelection>();
            _pageListChangedEvent = new PageListChangedEvent();
        }
Beispiel #4
0
        /// <summary>
        /// this one works on the dom passed to it
        /// </summary>
        /// <param name="dom"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public HtmlDom MakeDomRelocatable(HtmlDom dom, IProgress log)
        {
            var relocatableDom = dom.Clone();

            SetBaseForRelativePaths(relocatableDom, _folderPath, true);
            EnsureHasLinksToStylesheets(relocatableDom);
            UpdateStyleSheetLinkPaths(relocatableDom, _fileLocator, log);

            return relocatableDom;
        }
Beispiel #5
0
        public void Setup()
        {
            _storage = new Moq.Mock<IBookStorage>();
            _storage.Setup(x => x.GetLooksOk()).Returns(true);
            _bookDom = new HtmlDom(GetThreePageDom());
            _storage.SetupGet(x => x.Dom).Returns(() => _bookDom);
            _storage.SetupGet(x => x.Key).Returns("testkey");
            _storage.SetupGet(x => x.FileName).Returns("testTitle");
            _storage.SetupGet(x => x.BookType).Returns(Bloom.Book.Book.BookType.Publication);
            _storage.Setup(x => x.GetRelocatableCopyOfDom(It.IsAny<IProgress>())).Returns(()=>
                                                                                              {
                                                                                                  return
                                                                                                      _bookDom.Clone();
                                                                                              });// review: the real thing does more than just clone
            _storage.Setup(x => x.MakeDomRelocatable(It.IsAny<HtmlDom>(),It.IsAny<IProgress>())).Returns(
                (HtmlDom x, IProgress y) => {return x.Clone();});// review: the real thing does more than just clone

            _storage.Setup(x => x.GetFileLocator()).Returns(()=>_fileLocator.Object);

            _testFolder = new TemporaryFolder("BookTests");
            _tempFolder = new TemporaryFolder(_testFolder, "book");
            MakeSamplePngImageWithMetadata(Path.Combine(_tempFolder.Path,"original.png"));
            _storage.SetupGet(x => x.FolderPath).Returns(_tempFolder.Path);// review: the real thing does more than just clone

            _templateFinder = new Moq.Mock<ITemplateFinder>();
            _fileLocator = new Moq.Mock<IFileLocator>();
            string root = FileLocator.GetDirectoryDistributedWithApplication("BloomBrowserUI");
            string xMatter = FileLocator.GetDirectoryDistributedWithApplication("xMatter");
            string factoryCollections = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections");
            string templates = FileLocator.GetDirectoryDistributedWithApplication("factoryCollections","templates");
            _fileLocator.Setup(x => x.LocateFileWithThrow("languageDisplayTemplate.css")).Returns(root.CombineForPath("bookLayout","languageDisplayTemplate.css"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("previewMode.css")).Returns("../notareallocation/previewMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editMode.css")).Returns("../notareallocation/editMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editTranslationMode.css")).Returns("../notareallocation/editTranslationMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("editOriginalMode.css")).Returns("../notareallocation/editOriginalMode.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("basePage.css")).Returns("../notareallocation/basePage.css");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomBootstrap.js")).Returns("../notareallocation/bloomBootstrap.js");
            _fileLocator.Setup(x => x.LocateFileWithThrow("bloomPreviewBootstrap.js")).Returns("../notareallocation/bloomPreviewBootstrap.js");
            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter")).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateDirectory("Factory-XMatter", It.IsAny<string>())).Returns(xMatter.CombineForPath("Factory-XMatter"));
            _fileLocator.Setup(x => x.LocateFileWithThrow("Factory-XMatter".CombineForPath("Factory-XMatter.htm"))).Returns(xMatter.CombineForPath("Factory-XMatter", "Factory-XMatter.htm"));

            //warning: we're neutering part of what the code under test is trying to do here:
            _fileLocator.Setup(x => x.CloneAndCustomize(It.IsAny<IEnumerable<string>>())).Returns(_fileLocator.Object);

            _thumbnailer = new Moq.Mock<HtmlThumbNailer>(new object[] { 60 });
            _pageSelection = new Mock<PageSelection>();
            _pageListChangedEvent = new PageListChangedEvent();
        }
Beispiel #6
0
        /// <summary>
        /// this one works on the dom passed to it
        /// </summary>
        /// <param name="dom"></param>
        /// <param name="log"></param>
        /// <returns></returns>
        public HtmlDom MakeDomRelocatable(HtmlDom dom, IProgress log = null)
        {
            var relocatableDom = dom.Clone();

            SetBaseForRelativePaths(relocatableDom, _folderPath);
            EnsureHasLinksToStylesheets(relocatableDom);

            return relocatableDom;
        }