private BookStorage GetInitialStorageWithCustomHead(string head) { File.WriteAllText(_bookPath, "<html><head>" + head + " </head></body></html>"); var storage = new BookStorage(_folder.Path, _fileLocator, new BookRenamedEvent(), new CollectionSettings()); storage.Save(); return(storage); }
// // [Test] // public void Delete_IsDeleted() // { // BookStorage storage = GetInitialStorage(); // Assert.IsTrue(Directory.Exists(_folder.Path)); // Assert.IsTrue(storage.DeleteBook()); // Thread.Sleep(2000); // Assert.IsFalse(Directory.Exists(_folder.Path)); // } private BookStorage GetInitialStorage() { File.WriteAllText(_bookPath, "<html><head> href='file://blahblah\\editMode.css' type='text/css' /></head><body><div class='bloom-page'></div></body></html>"); var storage = new BookStorage(_folder.Path, _fileLocator, new BookRenamedEvent(), new CollectionSettings()); storage.Save(); return(storage); }
public void Save_BookHadOnlyPaperSizeStyleSheet_StillHasIt() { File.WriteAllText(_bookPath, "<html><head><link rel='stylesheet' href='Basic Book.css' type='text/css' /></head><body><div class='bloom-page'></div></body></html>"); var storage = new BookStorage(_folder.FolderPath, _fileLocator, new BookRenamedEvent(), new CollectionSettings()); storage.Save(); AssertThatXmlIn.HtmlFile(_bookPath).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'Basic Book')]", 1); }
public void Save_BookHadEditStyleSheet_NowHasPreviewAndBase() { File.WriteAllText(_bookPath, "<html><head> href='file://blahblah\\editMode.css' type='text/css' /></head><body><div class='bloom-page'></div></body></html>"); var storage = new BookStorage(_folder.FolderPath, _fileLocator, new BookRenamedEvent(), new CollectionSettings()); storage.Save(); AssertThatXmlIn.HtmlFile(_bookPath).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'basePage')]", 1); AssertThatXmlIn.HtmlFile(_bookPath).HasSpecifiedNumberOfMatchesForXpath("//link[contains(@href, 'preview')]", 1); }
private BookStorage GetInitialStorageWithCustomHtml(string html) { RobustFile.WriteAllText(_bookPath, html); var projectFolder = new TemporaryFolder("BookStorageTests_ProjectCollection"); var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection")); var storage = new BookStorage(_folder.Path, _fileLocator, new BookRenamedEvent(), collectionSettings); storage.Save(); return(storage); }
private BookStorage GetInitialStorageWithDifferentFileName(string bookName) { var bookPath = _folder.Combine(bookName + ".htm"); File.WriteAllText(bookPath, "<html><head> href='file://blahblah\\editMode.css' type='text/css' /></head><body><div class='bloom-page'></div></body></html>"); var projectFolder = new TemporaryFolder("BookStorageTests_ProjectCollection"); var collectionSettings = new CollectionSettings(Path.Combine(projectFolder.Path, "test.bloomCollection")); var storage = new BookStorage(_folder.Path, _fileLocator, new BookRenamedEvent(), collectionSettings); storage.Save(); return(storage); }
public void SetBookName_FolderWithNameAlreadyExists_AddsANumberToName() { using (var original = new TemporaryFolder(_folder, "original")) using (var x = new TemporaryFolder(_folder, "foo")) using (var y = new TemporaryFolder(_folder, "foo1")) using (var z = new TemporaryFolder(_folder, "foo2")) { File.WriteAllText(Path.Combine(original.Path, "original.htm"), "<html><head> href='file://blahblah\\editMode.css' type='text/css' /></head><body><div class='bloom-page'></div></body></html>"); var storage = new BookStorage(original.Path, _fileLocator, new BookRenamedEvent(), new CollectionSettings()); storage.Save(); Directory.Delete(z.Path); //so, we ask for "foo", but should get "foo2", because there is already a foo and foo1 var newBookName = Path.GetFileName(x.Path); storage.SetBookName(newBookName); var newPath = z.Combine("foo2.htm"); Assert.IsTrue(Directory.Exists(z.Path), "Expected folder:" + z.Path); Assert.IsTrue(File.Exists(newPath), "Expected file:" + newPath); } }