public void AddsRowLabels(string source)
        {
            SetupFor(source);
            var pageNumIndex = _sheet.GetColumnForTag(InternalSpreadsheet.PageNumberColumnLabel);

            Assert.That(_pageContentRows[0].GetCell(pageNumIndex).Content, Is.EqualTo("1"));
            Assert.That(_pageContentRows[1].GetCell(pageNumIndex).Content, Is.EqualTo("1"));
            Assert.That(_pageContentRows[2].GetCell(pageNumIndex).Content, Is.EqualTo("2"));
            Assert.That(_pageContentRows[0].GetCell(0).Content, Is.EqualTo(InternalSpreadsheet.PageContentRowLabel));
            Assert.That(_pageContentRows[1].GetCell(0).Content, Is.EqualTo(InternalSpreadsheet.PageContentRowLabel));
            Assert.That(_pageContentRows[2].GetCell(0).Content, Is.EqualTo(InternalSpreadsheet.PageContentRowLabel));
        }
Exemple #2
0
        public void OneTimeSetup()
        {
            _testFolder = new TemporaryFolder("SpreadsheetImporterWithBookTests");
            // We need 2 layers of temp folder because BringBookUpToDate will change the name of the book
            // folder to match an imported title.
            _bookFolder = new TemporaryFolder(_testFolder, "Book");
            var settings = new NewCollectionSettings();

            settings.Language1.Iso639Code = "en";
            settings.Language1.SetName("English", false);
            settings.SettingsFilePath = Path.Combine(_bookFolder.FolderPath, "dummy");

            var fileLocator = new BloomFileLocator(settings, new XMatterPackFinder(new string[] { }), ProjectContext.GetFactoryFileLocations(),
                                                   ProjectContext.GetFoundFileLocations(), ProjectContext.GetAfterXMatterFileLocations());
            var bookFilePath = Path.Combine(_bookFolder.FolderPath, "testBook.htm");

            if (File.Exists(bookFilePath))             // Shouldn't ever happen, but... just being careful.
            {
                RobustFile.Delete(bookFilePath);
            }
            _dom = SetupTestDom();
            // Write out our test book
            File.WriteAllText(bookFilePath, _dom.RawDom.OuterXml.ToString());
            var storage = new BookStorage(_bookFolder.FolderPath, fileLocator, new BookRenamedEvent(), settings);

            var book = new Bloom.Book.Book(new BookInfo(_bookFolder.FolderPath, true), storage, null,
                                           settings, new Bloom.Edit.PageSelection(),
                                           new PageListChangedEvent(), new BookRefreshEvent());

            // Create the regular production importer
            _importer = new SpreadsheetImporter(null, book, _bookFolder.FolderPath);

            // Set up the internal spreadsheet rows directly.
            var ss             = new InternalSpreadsheet();
            var columnForEn    = ss.AddColumnForLang("en", "English");
            var columnForImage = ss.GetColumnForTag(InternalSpreadsheet.ImageSourceColumnLabel);

            var newTitle = "My new book title";
            var titleRow = new ContentRow(ss);

            titleRow.AddCell(InternalSpreadsheet.BookTitleRowLabel);
            titleRow.SetCell(columnForEn, newTitle);

            var coverImageRow = new ContentRow(ss);

            coverImageRow.AddCell(InternalSpreadsheet.CoverImageRowLabel);
            coverImageRow.SetCell(columnForImage, Path.Combine("images", "Othello 199.jpg"));

            _importer.Import(ss);

            _resultElement = ReadResultingBookToXml(newTitle);
        }
Exemple #3
0
        public void ImageSourceXmatterTest(string source)
        {
            SetupFor(source);
            var imageSourceCol = _sheet.GetColumnForTag(InternalSpreadsheet.ImageSourceColumnLabel);

            var coverImageRow = _rows.Find(x => x.MetadataKey.Equals("[coverImage]"));

            Assert.That(coverImageRow, Is.Not.Null);
            Assert.That(coverImageRow.GetCell(imageSourceCol).Content, Is.EqualTo(Path.Combine("images", "microwave1.png")));

            var licenseImageRow = _rows.Find(x => x.MetadataKey.Equals("[licenseImage]"));

            Assert.That(licenseImageRow, Is.Null);

            var backImageRow = _rows.Find(x => x.MetadataKey.Equals("[outside-back-cover-bottom-html]"));

            Assert.That(backImageRow, Is.Not.Null);
            Assert.That(backImageRow.GetCell(imageSourceCol).Content, Is.EqualTo(Path.Combine("images", "BloomWithTaglineAgainstLight.svg")));
        }