Addressig remainign warnings in Chapter 4
MODIFY
src/Chapter04.Tests/Listing04.48.Tests.cs
src/Chapter04.Tests/Listing04.48.Tests.cs
@@ -8,38 +8,32 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_48.Tests
[TestMethod]
public void Main_Input4_ValidInput()
{
- Program.input = "4";
-
const string expected =
@"";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
- expected, Program.Main);
+ expected, () => Program.Main("4"));
}
[TestMethod]
public void Main_Input0_InvalidInput()
{
- Program.input = "0";
-
const string expected =
@"
ERROR: Enter a value from 1-9. Push ENTER to quit";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
- expected, Program.Main);
+ expected, () => Program.Main("0"));
}
[TestMethod]
public void Main_InputQuit_ExitProgram()
{
- Program.input = "quit";
-
const string expected =
@"";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
- expected, Program.Main);
+ expected, () => Program.Main("quit"));
}
}
}
\ No newline at end of file

MODIFY
src/Chapter04/Chapter04.csproj
src/Chapter04/Chapter04.csproj
<!-- IDE0060: Remove unused parameter suggestion ignored since listing is not complete -->
<ExpectedWarnings>$(ExpectedWarnings),CA1052,IDE0059,IDE0060</ExpectedWarnings>
</PropertyGroup>
- <PropertyGroup>
- <!-- CS1030 results from an explicit #warning preprocessor command -->
- <ExpectedWarnings>$(ExpectedWarnings),1030</ExpectedWarnings>
- </PropertyGroup>
<Import Project="..\Chapter.props" />
<ItemGroup>
<Compile Include="..\Shared\Program.cs">

MODIFY
src/Chapter04/Listing04.48.InputValidation.cs
src/Chapter04/Listing04.48.InputValidation.cs
-#pragma warning disable CS0219 // Variable is assigned but its value is never used
-
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_48
{
public class Program
{
- public static void Main()
+ public static void Main(params string[] args)
{
+ string input = args[0];
// ...
// Check the current player's input
@@ -38,9 +37,5 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_48
// ...
}
-
-#pragma warning disable IDE1006 // Promoted to a property to support testing.
- public static string input { get; set; } = "Let the game begin!";
-#pragma warning restore IDE1006 // Naming Styles
}
}

Addressig remainign warnings in Chapter 4