Errata for Pragmatic Unit Testing in C# with NUnit (2nd edition)
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 P2.0,
released over 3 years 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 |
| 2009 |
egNyj |
#50104: Simply wish to say your post is as astounding. The claenress in your post is just cool and i can assume you are an expert on this subject. Fine with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please continue the enjoyable work.--yAQdFoHUEOGqBTZqSym #50104: Simply wish to say your post is as astounding. The claenress in your post is just cool and i can assume you are an expert on this subject. Fin ...more...
|
P2.0
01-Nov-12
|
|
Stuff To Be Considered in the Next Edition
| PDF |
Paper |
Description |
Found in |
Fixed in |
| 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
|
|
|
151 |
#31752: The line
DatabaseConnection dbc = new DatabaseConnection();
should be above the try block.--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
|
|
|
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
|
|
|
201 |
#39950: I have found an error in the book and I want to report it. The error is slight but I consider it worth mentioning.
On page 201, Appendix A, A.10 - C# 2.0-Specific issues there is this C# code :
[Test]
public void NullableInt() {
int? first;
Nullable<int> second;
Assert.IsNull(first);
Assert.IsNull(second);
}
This code will not work (not even compile, to be more precise) since the local variables "first" and "second" are not initialized before they are used. A correct form would be :
[Test]
public void NullableInt() {
int? first = null;
Nullable<int> second = null;
Assert.IsNull(first);
Assert.IsNull(second);
}
Otherwise a GREAT book!--Andrei Rinea #39950: I have found an error in the book and I want to report it. The error is slight but I consider it worth mentioning.
On page 201, Appendix A, ...more...
|
P1.1
13-Jul-09
|
|