Esempio n. 1
0
        public EpubItem MockTocEpubItem()
        {
            var ncxItem = new EpubItem()
            {
                AbsolutePath = "OEPBS/toc.ncx"
            };

            return(ncxItem);
        }
Esempio n. 2
0
        public void Test_PrefixAsInt()
        {
            int actual = EpubItem.PrefixAsInt("OEBPS/Images/cover.html");

            Assert.AreEqual(0, actual);
            actual = EpubItem.PrefixAsInt("OEBPS/Images/0006_010507301155442407.jpg");
            Assert.AreEqual(6, actual);
            actual = EpubItem.PrefixAsInt("OEBPS/Images/0015.jpeg");
            Assert.AreEqual(15, actual);
        }
Esempio n. 3
0
        public void TestFindTocEntry_DoesNotExist()
        {
            XDocument doc         = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.tocGifting.ncx");
            var       mockNcxItem = new EpubItem()
            {
                AbsolutePath = "OEPBS/toc.ncx"
            };
            var api    = Utils.FakeAbsolutePathIndex(doc, "OEPBS/toc.ncx");
            var toc    = new ToC(doc, mockNcxItem, api);
            var actual = toc.FindTocEntry("OEPBS/Text/0002_Chapter_A.xhtml");

            Assert.IsNull(actual.entries);
        }
Esempio n. 4
0
        public void TestRoundTripParseToCWithNesting()
        {
            XDocument doc         = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.tocWithNesting.ncx");
            var       mockNcxItem = new EpubItem()
            {
                AbsolutePath = "toc.ncx"
            };
            var api = Utils.FakeAbsolutePathIndex(doc, "toc.ncx");

            var toc   = new ToC(doc, mockNcxItem, api);
            var doc2  = toc.ToXDocument();
            var delta = XmlCompare.ElementSame(doc.Root, doc2.Root);

            Assert.IsTrue(delta.AreSame);
        }
Esempio n. 5
0
        public void TestBuildScrToTitleMap()
        {
            XDocument doc         = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.tocGifting.ncx");
            var       mockNcxItem = new EpubItem()
            {
                AbsolutePath = "OEPBS/toc.ncx"
            };
            var api    = Utils.FakeAbsolutePathIndex(doc, "OEPBS/toc.ncx");
            var toc    = new ToC(doc, mockNcxItem, api);
            var actual = toc.BuildScrToTitleMap();

            Assert.AreEqual(6, actual.Count);
            Assert.AreEqual("Splash pages", actual["OEPBS/Text/0000_Splash_pages.xhtml"]);
            Assert.AreEqual("Main Story: Chapter 1", actual["OEPBS/Text/0001_Chapter_1.xhtml"]);
            Assert.AreEqual("Chapter 3", actual["OEPBS/Text/0003_Chapter_3.xhtml"]);
        }
Esempio n. 6
0
        public void TestCalcNavMapDepth_Expect2_ThenExpect3()
        {
            XDocument doc         = Utils.ReadXmlResource("UnitTestMergeWebToEpub.TestData.toc.ncx");
            var       mockNcxItem = new EpubItem()
            {
                AbsolutePath = "toc.ncx"
            };
            var api = Utils.FakeAbsolutePathIndex(doc, "toc.ncx");

            var toc = new ToC(doc, mockNcxItem, api);

            Assert.AreEqual(2, toc.CalcNavMapDepth());

            toc.Entries[2].Children[0].Children.Add(new TocEntry());
            Assert.AreEqual(3, toc.CalcNavMapDepth());
        }
Esempio n. 7
0
        public static Dictionary <string, EpubItem> FakeAbsolutePathIndex(XDocument doc, string ncxFileName)
        {
            var    index     = new Dictionary <string, EpubItem>();
            string ncxFolder = ncxFileName.GetZipPath();

            foreach (var e in doc.Root.Descendants(Epub.ncxNs + "content"))
            {
                string relativePath = e.Attribute("src").Value;
                string absolute     = ZipUtils.RelativePathToAbsolute(ncxFolder, relativePath);
                index[absolute] = new EpubItem()
                {
                    AbsolutePath = absolute
                };
            }
            return(index);
        }
Esempio n. 8
0
        /// <summary>コンストラクタ Initializes a new instance of the <see cref="AceViewModel"/> class. </summary>
        public AceViewModel()
        {
            this.CurrentItemViewIndex.Value = 0;

            this.Items.ObserveAddChanged().Delay(TimeSpan.FromSeconds(0.1)).Subscribe(_ => this.UpData());

            // アイテムViewモードのリスト選択。未選択状態(-1)であれば強制的に0とする
            this.CurrentItemViewIndex.Subscribe(x => this.CurrentItemViewIndex.Value = x == -1 ? 0 : x);

            // 初期1個を追加
            var sampleepub = new EpubItem("sample.epub", 1);

            sampleepub.CurState.Value = EpubItem.State.Completed;

            this.Items.AddOnScheduler(sampleepub);

            this.EnableAceCheck.Value = AceUtil.CanRun;

            this.AceVersionTxt.Value  = string.IsNullOrEmpty(AceUtil.Version) ? string.Empty : string.Format("{0}\r\n{1}", AceUtil.Path, AceUtil.Version);
            this.NodeVersionTxt.Value = string.Format("{0}", AceUtil.NodeVersion);

            // 上部タブ的メニュー
            this.InViewIsSelected0.Where(x => x).Subscribe(_ =>
            {
                this.InViewSelectedIndex.Value = 0;
                AceViewModel.IsShowBrowser.TurnOn();
            });
            this.InViewIsSelected1.Where(x => x).Subscribe(_ =>
            {
                this.InViewSelectedIndex.Value = 1;
                AceViewModel.IsShowBrowser.TurnOff();
            });
            this.InViewIsSelected2.Where(x => x).Subscribe(_ =>
            {
                this.InViewSelectedIndex.Value = 2;
                AceViewModel.IsShowBrowser.TurnOff();
            });
        }
Esempio n. 9
0
 public byte[] MakeDummyImage(EpubItem item)
 {
     return(Encoding.UTF8.GetBytes(item.AbsolutePath));
 }