Updated Chapter 4 code to use raw string literals
MODIFY
src/Chapter04.Tests/Listing04.04.Tests.cs
src/Chapter04.Tests/Listing04.04.Tests.cs
@@ -8,9 +8,10 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_04.Tests
[TestMethod]
public void Main_AdditionOperatorWithNonNumericType_StringConcatenated()
{
- const string expected =
-@"The original Tacoma Bridge in Washington
-was brought down by a 42 mile/hour wind.";
+ const string expected = """
+ The original Tacoma Bridge in Washington
+ was brought down by a 42 mile/hour wind.
+ """;
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, FortyTwo.Main);

MODIFY
src/Chapter04.Tests/Listing04.09.Tests.cs
src/Chapter04.Tests/Listing04.09.Tests.cs
@@ -9,8 +9,10 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_09.Tests
[TestMethod]
public void Main_OverflowBoundsOfFloat_WriteInfinity()
{
- string expected = $"-{NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}\n" +
- $"{NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}";
+ string expected = $"""
+ -{NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}
+ {NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}
+ """;
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04.Tests/Listing04.21.Tests.cs
src/Chapter04.Tests/Listing04.21.Tests.cs
@@ -9,11 +9,12 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_21.Tests
[TestMethod]
public void Main_Enter1TryToPlayAgainstComputer_ComputerPathSelected()
{
- const string expected =
-@"1 - Play against the computer
+ const string expected = """
+ 1 - Play against the computer
2 - Play against another player.
Choose:<<1
->>Play against computer selected.";
+ >>Play against computer selected.
+ """;
ConsoleAssert.Expect(
expected, TicTacToe.Main);

MODIFY
src/Chapter04.Tests/Listing04.41.Tests.cs
src/Chapter04.Tests/Listing04.41.Tests.cs
@@ -8,10 +8,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_41.Tests
[TestMethod]
public void Main_BitwiseOperators_WriteAndOrXORValues()
{
- const string expected =
-@"and = 4
+ const string expected = """
+ and = 4
or = 15
-xor = 11";
+ xor = 11
+ """;
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04.Tests/Listing04.43.Tests.cs
src/Chapter04.Tests/Listing04.43.Tests.cs
@@ -8,10 +8,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_43.Tests
[TestMethod]
public void Main_LogicalAssignmentOperators_WriteAssignmentResult()
{
- const string expected =
-@"and = 4
+ const string expected = """
+ and = 4
or = 15
-xor = 11";
+ xor = 11
+ """;
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04.Tests/Listing04.49.Tests.cs
src/Chapter04.Tests/Listing04.49.Tests.cs
@@ -18,9 +18,10 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_49.Tests
[TestMethod]
public void Main_Input0_InvalidInput()
{
- const string expected =
-@"
-ERROR: Enter a value from 1-9. Push ENTER to quit";
+ const string expected = """
+ ERROR: Enter a value from 1-9.
+ Push ENTER to quit
+ """;
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, () => Program.Main("0"));

MODIFY
src/Chapter04.Tests/Listing04.50.Tests.cs
src/Chapter04.Tests/Listing04.50.Tests.cs
@@ -25,8 +25,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_50.Tests
public void ValidateAndMove_Input0_InvalidInput()
{
const string expected =
-@"
-ERROR: Enter a value from 1-9. Push ENTER to quit";
+ @"ERROR: Enter a value from 1-9. Push ENTER to quit";
int[] playerPositions = new int[1];
int currentPlayer = 0;

MODIFY
src/Chapter04/Listing04.21.IfElseStatement.cs
src/Chapter04/Listing04.21.IfElseStatement.cs
@@ -10,10 +10,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_21
string input;
// Prompt the user to select a 1- or 2- player game
- Console.Write(
- "1 - Play against the computer\n" +
- "2 - Play against another player.\n" +
- "Choose:"
+ Console.Write($"""
+ 1 - Play against the computer
+ 2 - Play against another player.
+ Choose:
+ """
);
input = Console.ReadLine();

MODIFY
src/Chapter04/Listing04.41.BitwiseOperators.cs
src/Chapter04/Listing04.41.BitwiseOperators.cs
@@ -9,8 +9,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_41
and = 12 & 7; // and = 4
or = 12 | 7; // or = 15
xor = 12 ^ 7; // xor = 11
- Console.WriteLine(
- $"and = { and } \nor = { or }\nxor = { xor }");
+ Console.WriteLine( $"""
+ and = { and }
+ or = { or }
+ xor = { xor }
+ """);
#endregion INCLUDE
}
}

MODIFY
src/Chapter04/Listing04.43.LogicalAssignmentOperators.cs
src/Chapter04/Listing04.43.LogicalAssignmentOperators.cs
@@ -11,8 +11,11 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_43
or |= 7; // or = 15
xor ^= 7; // xor = 11
#endregion HIGHLIGHT
- Console.WriteLine(
- $"and = { and } \nor = { or } \nxor = { xor }");
+ Console.WriteLine( $"""
+ and = {and}
+ or = {or}
+ xor = {xor}
+ """);
#endregion INCLUDE
}
}

MODIFY
src/Chapter04/Listing04.49.InputValidation.cs
src/Chapter04/Listing04.49.InputValidation.cs
@@ -31,9 +31,10 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_49
}
else
{
- Console.WriteLine(
- "\nERROR: Enter a value from 1-9. "
- + "Push ENTER to quit");
+ Console.WriteLine( $"""
+ ERROR: Enter a value from 1-9.
+ Push ENTER to quit
+ """);
}
// ...

Updated Chapter 4 code to use raw string literals