Skip to content

Commit

Permalink
fix: 4.24 Logic and tests (#758)
Browse files Browse the repository at this point in the history
Fixes #737
  • Loading branch information
BenjaminMichaelis committed Apr 4, 2024
1 parent bea2811 commit d11cf44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Errata.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ Zhou Jing | 18 | 926-927 | Change 'LastName' references to be 'FirstName' in par
Jinhang He | 5 | 255 | Edit listing 5.20 to used `image[index]` for the second print statement
Zhou Jing | 18 | 908 | Change comment in Listing 18.21 to "Restrict the attribute to properties and fields" from "Restrict the attribute to properties and methods"
Zhou Jing | 23 | 1080 | Change "DWORD flProtect); // The type of memory allocation" to "// The type of memory protection"
Zhou Jing | 22 | 1065 - 1066 | Changed 'Thread' to 'Task' and "Application exiting" to "Application shutting down"
Zhou Jing | 22 | 1065 - 1066 | Changed 'Thread' to 'Task' and "Application exiting" to "Application shutting down"
Zhou Jing | 4 | 161 | Fix `input < 9` to `input < 0` in Listing 4.24
14 changes: 12 additions & 2 deletions src/Chapter04.Tests/Listing04.24.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_24.Tests;
public class ProgramTests
{
[TestMethod]
public void Main_Input8_ExitProgram()
public void Main_InputNegative1_ExitProgram()
{
const string expected =
"Exiting";

ConsoleAssert.Expect(
expected, ()=>Program.Main("8"));
expected, ()=>Program.Main("-1"));
}

[TestMethod]
Expand All @@ -24,4 +24,14 @@ public void Main_Input10_ProgramDoesNotExit()
ConsoleAssert.Expect(
expected, ()=>Program.Main("10"));
}

[TestMethod]
public void Main_Input0_ProgramDoesNotExit()
{
const string expected =
"";

ConsoleAssert.Expect(
expected, () => Program.Main("0"));
}
}
4 changes: 2 additions & 2 deletions src/Chapter04/Listing04.24.NoCodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public static void Main(params string[] args)
int input = int.Parse(args[0]);

#region INCLUDE
if (input < 9)
if (input < 0)
#region HIGHLIGHT
Console.WriteLine("Exiting");
#endregion HIGHLIGHT
#endregion HIGHLIGHT
#endregion INCLUDE
}
}

0 comments on commit d11cf44

Please sign in to comment.