Skip to content

Commit

Permalink
fix: 4.24 Logic and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminMichaelis committed Mar 27, 2024
1 parent ff1a0a4 commit 68f5056
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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 68f5056

Please sign in to comment.