Errata for Pragmatic Unit Testing in C# with NUnit
We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P1.1,
released about 1 year ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 10 |
|
#30332: First line of the page marked on the page as page 10 says:
"... until then it will definitely longer ..."
and should probably say:
"... until then it will definitely take longer ..."--AD #30332: First line of the page marked on the page as page 10 says:
"... until then it will definitely longer ..."
and should probably say:
...more...
|
P1.0
06-Jan-08
|
|
| 39 |
|
#33945: The line "Is.AtMost() is just an alias for Is.LessThenOrEqualTo()," should be "Is.AtMost() is just an alias for Is.LessThanOrEqualTo(),"--Miquel
|
P1.1
12-Aug-08
|
|
| 51 |
|
#29785: This is regarding the paragraph that begins with "In this example, the method PerFixtureTest will be called .....". I believe that the contention of the authors that TestFixtureSetup and TestFixtureTeardown being called after each test is wrong. These two methods are called only once per [TestFixture], and not once per [Test] attribute.. Hence the sequence of events, relating to the example on pages 50-51 should be:
[TestFixtureSetup]
[Setup] ---> AccountAcce()
[Teardown]
[Setup] ---> EmployeeAccess()
[Teardown]
[TestFixtureTeardown]
Thank you.--Ameet Jayawant #29785: This is regarding the paragraph that begins with "In this example, the method PerFixtureTest will be called .....". I believe that the content ...more...
|
P1.0
24-Oct-07
|
|
|
53 |
#36590: First line on page 53:
Assert.That(actualCollection, List.Contains(expectedValue)
Suggestion: use Has.Member in NUnit 2.4.2 instead of the above syntax:
Assert.That(actualCollection, Has.Member(expectedValue) );
#36590: First line on page 53:
Assert.That(actualCollection, List.Contains(expectedValue)
Suggestion: use Has.Member in NUnit 2.4.2 instead of the ...more...
|
P1.0
24-Dec-08
|
|
|
105 |
#31756: "Sometimes the controller is told directly and in NUnit's mocks" - "and" should be "as". (1st paragraph)--Bill Sorensen
|
P1.0
26-Apr-08
|
|
| 124 |
|
#36065: "Code analysis tools and mutation testers can help close this gap, which we’ll discuss in Chapter 7."
is written within chapter 7 itself. Nester isn't mentioned until chapter 8.6.--Andrew Grimm #36065: "Code analysis tools and mutation testers can help close this gap, which we’ll discuss in Chapter 7."
is written within chapter 7 itself. N ...more...
|
P1.1
22-Nov-08
|
|
|
138 |
#31610: On p. 138 of your book, you mention the issue of accessing internal members when test code is in a separate assembly. There is another option: use the InternalsVisibleTo attribute to make the unit test assembly a friend assembly.
--Bill Sorensen #31610: On p. 138 of your book, you mention the issue of accessing internal members when test code is in a separate assembly. There is another option: ...more...
|
P1.1
07-Apr-08
|
|
|
151 |
#31752: The line
DatabaseConnection dbc = new DatabaseConnection();
should be above the try block.--Bill Sorensen
|
P1.0
26-Apr-08
|
|
|
164 |
#31757: In the SaveAndRestore test, it might be a better example if it were refactored so that the tests did not use file I/O.--Bill Sorensen
|
P1.0
26-Apr-08
|
|
|
164 |
#31758: In the SaveAndRestore test, it might be a better example if it were refactored so that the tests did not use file I/O.--Bill Sorensen
|
P1.0
26-Apr-08
|
|
|
167 |
#39276: Summary:
The code for the method createRecipe is flawed, and will not record information past the INGREDIENTS_TOKEN line of the lines ICollection into the new Recipe object.
Detail:
When I got the RecipeForm.cs file working, I found a bug in the CreateRecipe method in the RecipeFile class. Without the change, the code will never load the file properly. In the switch (tokens[0]) statement, the original code used a for loop to read the string collection lines after the INGREDIENTS_TOKEN token. This for statement doesn't work, because there is nothing advancing the line variable to the next string in the lines ICollection.
I changed the code to use the default: case to read in the ingredients from the file. This is by no means a bullet proof solution (what if there are no ingredients to read?). I'm sure the best solution is to advance the line variable within the for loop, but I couldn't discover how to do that.
I encountered this using Visual Studio 2005.
Original code:
foreach (string line in lines) {
string[] tokens = line.Split(delim, 2);
switch (tokens[0]) {
case NAME_TOKEN: {
recipe.Name = tokens[1];
break;
}
case INGREDIENTS_TOKEN: {
try {
int count = Int32.Parse(tokens[1]);
for (int i = 0; i < count; i++) {
recipe.AddIngredient(line);
}
} catch (IOException error) {
throw new RecipeFormatException(
"Bad ingredient count: " + error.Message);
}
break;
}
}
My change:
foreach (string line in lines) {
string[] tokens = line.Split(delim, 2);
switch (tokens[0]) {
case NAME_TOKEN: {
recipe.Name = tokens[1];
break;
}
case INGREDIENTS_TOKEN: {
try {
int count = Int32.Parse(tokens[1]);
//for (int i = 0; i < count; i++) {
// recipe.AddIngredient(line);
//}
} catch (IOException error) {
throw new RecipeFormatException(
"Bad ingredient count: " + error.Message);
}
break;
}
default: {
recipe.AddIngredient(line);
break;
}
}
Another option is to put this in another loop structure.--Jess Stuart #39276: Summary:
The code for the method createRecipe is flawed, and will not record information past the INGREDIENTS_TOKEN line of the lines ICollec ...more...
|
P1.1
29-May-09
|
|
|
179 |
#31754: The line
new RecipieForm(recipe as Recipe);
does not look right.
recipe is type FakeRecipeFile, which is a RecipeFile (and would not need an as cast), which does not seem to be a Recipe.--Bill Sorensen #31754: The line
new RecipieForm(recipe as Recipe);
does not look right.
recipe is type FakeRecipeFile, which is a RecipeFile (and would not need ...more...
|
P1.0
26-Apr-08
|
|
|
180 |
#31755: For the line
ExpectModal(PASSWORD_FAILURE, "PasswordFailureOkHandler");
shouldn't that be
ExpectModal(PASSWORD_FAILURE, "MessageBoxOkHandler");
?--Bill Sorensen
|
P1.0
26-Apr-08
|
|
|
201 |
#31751: The NullableInt example won't compile due to unassigned variables. In any case the advice is incorrect - Nullable types with null values do equate to null (Equals is overloaded).--Bill Sorensen #31751: The NullableInt example won't compile due to unassigned variables. In any case the advice is incorrect - Nullable types with null values do eq ...more...
|
P1.0
26-Apr-08
|
|