Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/BloomExe/Book/Book.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,19 @@ public class Book
/// </summary>
public bool WriteFontFaces = true;

//for moq'ing only; parameterless ctor required by Moq
// For moq'ing only; parameterless ctor required by Moq.
public Book()
: this(false)
{
Guard.Against(!Program.RunningUnitTests, "Only use this ctor for tests!");
}

// Allow specific subclasses (like ErrorBook) to bypass the unit-test guard.
protected Book(bool allowNonTestCtor)
{
if (!allowNonTestCtor)
{
Guard.Against(!Program.RunningUnitTests, "Only use this ctor for tests!");
}
}

public Book(BookInfo info = null, IBookStorage storage = null)
Expand Down
8 changes: 3 additions & 5 deletions src/BloomExe/Book/ErrorBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public class ErrorBook : Book
private bool _canDelete;

/// <summary>
/// this is a bit of a hack to handle representing a book for which we got an exception while loading the storage... a better architecture wouldn't have this...
/// This is a bit of a hack to handle representing a book for which we got an exception while loading the storage.
/// A better architecture wouldn't have this.
/// </summary>
public ErrorBook(Exception exception, string folderPath, bool canDelete)
: base(true)
{
// ENHANCE: Address that a Guard fails when this constructor is called.
// This class inherits from Book. So it calls Book's default constructor here.
// But Book's default constructor has a Guard that says it's only supposed to be called from the unit tests.
// One potential route is to create an interface... IBook or ISimpleBook
Exception = exception;
_folderPath = folderPath;
_canDelete = canDelete;
Expand Down
Loading