diff --git a/src/Chapter02.Tests/Listing02.11.Tests.cs b/src/Chapter02.Tests/Listing02.11.Tests.cs new file mode 100644 index 000000000..560fd7b5d --- /dev/null +++ b/src/Chapter02.Tests/Listing02.11.Tests.cs @@ -0,0 +1,18 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_11.Tests +{ + [TestClass] + public class SingleQuoteTests + { + [TestMethod] + public void Main_WriteSingleQuote() + { + const string expected = + @"'"; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, SingleQuote.Main); + } + } +} \ No newline at end of file diff --git a/src/Chapter02.Tests/Listing02.22.Tests.cs b/src/Chapter02.Tests/Listing02.22.Tests.cs new file mode 100644 index 000000000..1d88abffe --- /dev/null +++ b/src/Chapter02.Tests/Listing02.22.Tests.cs @@ -0,0 +1,15 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_22.Tests +{ + [TestClass] + public class ProgramTests + { + [TestMethod] + [ExpectedException(typeof(System.OverflowException))] + public void Main_IntegerOverFlow_ExceptionThrown() + { + IntelliTect.TestTools.Console.ConsoleAssert.Execute("", Program.Main); + } + } +} \ No newline at end of file diff --git a/src/Chapter02.Tests/Listing02.28.Tests.cs b/src/Chapter02.Tests/Listing02.28.Tests.cs new file mode 100644 index 000000000..fd28426d3 --- /dev/null +++ b/src/Chapter02.Tests/Listing02.28.Tests.cs @@ -0,0 +1,17 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_28.Tests +{ + [TestClass] + public class ProgramTests + { + [TestMethod] + public void Main_PrintBoolConvertedToString() + { + const string expected = "True"; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, Program.Main); + } + } +} \ No newline at end of file diff --git a/src/Chapter02.Tests/Listing02.29.Tests.cs b/src/Chapter02.Tests/Listing02.29.Tests.cs new file mode 100644 index 000000000..a34389075 --- /dev/null +++ b/src/Chapter02.Tests/Listing02.29.Tests.cs @@ -0,0 +1,29 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_29.Tests +{ + [TestClass] + public class ProgramTests + { + [TestMethod] + public void Main_TryParseStringValidNumber_CorrectlyParsed() + { + const string expected = + @"Enter a number: <<42>>"; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, Program.Main); + } + + [TestMethod] + public void Main_TryParseStringNonNumber_IncorrectInput() + { + const string expected = +@"Enter a number: <>The text entered was not a valid number."; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, Program.Main); + } + } +} \ No newline at end of file diff --git a/src/Chapter02/Listing02.01-2.06.SpecifyingLiteralValues.cs b/src/Chapter02/Listing02.01-2.06.SpecifyingLiteralValues.cs deleted file mode 100644 index f1a966589..000000000 --- a/src/Chapter02/Listing02.01-2.06.SpecifyingLiteralValues.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_01To06 -{ - public class Program - { - public static void Main() - { - //begin listing 2.1 - System.Console.WriteLine(42); - System.Console.WriteLine(1.618034); - //end listing 2.1 - - //begin listing 2.2 - System.Console.WriteLine(1.618033988749895); - //end listing 2.2 - - //begin listing 2.3 - System.Console.WriteLine(1.618033988749895M); - //end listing 2.3 - - //begin listing 2.4 - System.Console.WriteLine(6.023E23F); - //end listing 2.4 - - //begin listing 2.5 - //Display the value 42 using a hexadecimal literal - System.Console.WriteLine(0x002A); - //end listing 2.5 - - //begin listing 2.6 - //Displays "0x2A" - System.Console.WriteLine($"0x{42:X}"); - //end listing 2.6 - } - } -}