diff --git a/src/Chapter04.Tests/Listing04.25B.IdenticalInFunctionality.Tests.cs b/src/Chapter04.Tests/Listing04.26.IdenticalInFunctionality.Tests.cs similarity index 96% rename from src/Chapter04.Tests/Listing04.25B.IdenticalInFunctionality.Tests.cs rename to src/Chapter04.Tests/Listing04.26.IdenticalInFunctionality.Tests.cs index 2b89d0966..c415eddcc 100644 --- a/src/Chapter04.Tests/Listing04.25B.IdenticalInFunctionality.Tests.cs +++ b/src/Chapter04.Tests/Listing04.26.IdenticalInFunctionality.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_25B.Tests +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26.Tests { [TestClass] public class ProgramTests diff --git a/src/Chapter04/Listing04.25B.IdenticalInFunctionality.cs b/src/Chapter04/Listing04.26.IdenticalInFunctionality.cs similarity index 97% rename from src/Chapter04/Listing04.25B.IdenticalInFunctionality.cs rename to src/Chapter04/Listing04.26.IdenticalInFunctionality.cs index 07b10204b..4b8f209a7 100644 --- a/src/Chapter04/Listing04.25B.IdenticalInFunctionality.cs +++ b/src/Chapter04/Listing04.26.IdenticalInFunctionality.cs @@ -1,6 +1,6 @@ using System; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_25B +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26 { public class Program { diff --git a/src/Chapter05.Tests/Listing05.02.SimpleMethodCall.cs b/src/Chapter05.Tests/Listing05.02.SimpleMethodCall.cs new file mode 100644 index 000000000..a911c826a --- /dev/null +++ b/src/Chapter05.Tests/Listing05.02.SimpleMethodCall.cs @@ -0,0 +1,20 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_02.Tests +{ + [TestClass] + public class HeyYouTests + { + [TestMethod] + public void Main_MethodCalls_MethodsCalledSuccessfully() + { + const string expected = +@"Hey you!Enter your first name: <>Enter your last name: <>Your full name is Inigo Montoya."; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, HeyYou.Main); + } + } +} diff --git a/src/Chapter05.Tests/Listing05.08.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs b/src/Chapter05.Tests/Listing05.08.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs new file mode 100644 index 000000000..54c22e6bf --- /dev/null +++ b/src/Chapter05.Tests/Listing05.08.SpecifyingTheUsingDirectiveInsideANamespaceDeclaration.cs @@ -0,0 +1,18 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_08.Tests +{ + [TestClass] + public class HelloWorldTests + { + [TestMethod] + public void Main_UsingToAvoidFullyQualifying_MethodCalledAsExpected() + { + const string expected = + @"Hello, my name is Inigo Montoya"; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, HelloWorld.Main); + } + } +} diff --git a/src/Chapter05.Tests/Listing05.09.UsingStaticDirective.cs b/src/Chapter05.Tests/Listing05.09.UsingStaticDirective.cs new file mode 100644 index 000000000..13a609148 --- /dev/null +++ b/src/Chapter05.Tests/Listing05.09.UsingStaticDirective.cs @@ -0,0 +1,21 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_09.Tests +{ + [TestClass] + public class HeyYouTests + { + [TestMethod] + public void Main_StaticUsing_MethodsCalledNormally() + { + const string expected = +@"Hey you! +Enter your first name: <>Enter your last name: <>Your full name is Inigo Montoya."; + + IntelliTect.TestTools.Console.ConsoleAssert.Expect( + expected, HeyYou.Main); + } + } +} diff --git a/src/Chapter04.Tests/Listing04.26.Tests.cs b/src/Chapter05.Tests/Listing05.28.Tests.cs similarity index 91% rename from src/Chapter04.Tests/Listing04.26.Tests.cs rename to src/Chapter05.Tests/Listing05.28.Tests.cs index 244ced2d8..a7a4420ad 100644 --- a/src/Chapter04.Tests/Listing04.26.Tests.cs +++ b/src/Chapter05.Tests/Listing05.28.Tests.cs @@ -1,6 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26.Tests +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28.Tests { [TestClass] public class LeveragingTryParseTests diff --git a/src/Chapter05/Listing05.09.UsingStaticDirective.cs b/src/Chapter05/Listing05.09.UsingStaticDirective.cs index 0e1fee40a..a061e976b 100644 --- a/src/Chapter05/Listing05.09.UsingStaticDirective.cs +++ b/src/Chapter05/Listing05.09.UsingStaticDirective.cs @@ -2,9 +2,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_09 { using static System.Console; - class HeyYou + public class HeyYou { - static void Main() + public static void Main() { string firstName; string lastName; diff --git a/src/Chapter04/Listing04.26.TryCatch.cs b/src/Chapter05/Listing05.28.TryCatch.cs similarity index 92% rename from src/Chapter04/Listing04.26.TryCatch.cs rename to src/Chapter05/Listing05.28.TryCatch.cs index fe8683d1a..ea6dd0225 100644 --- a/src/Chapter04/Listing04.26.TryCatch.cs +++ b/src/Chapter05/Listing05.28.TryCatch.cs @@ -1,4 +1,4 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26 +namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_28 { public class LeveragingTryParse { diff --git a/src/Chapter05/Listing05.33.ImplicitLocalVariablesWithAnonymousTypes.cs b/src/Chapter05/Listing05.33.ImplicitLocalVariablesWithAnonymousTypes.cs deleted file mode 100644 index 02baec98e..000000000 --- a/src/Chapter05/Listing05.33.ImplicitLocalVariablesWithAnonymousTypes.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter05.Listing05_33 -{ - using System; - - public class Program - { - public static void Main() - { - var patent1 = - new - { - Title = "Bifocals", - YearOfPublication = "1784" - }; - var patent2 = - new - { - Title = "Phonograph", - YearOfPublication = "1877" - }; - var patent3 = - new - { - patent1.Title, - Year = patent1.YearOfPublication - }; - - System.Console.WriteLine("{0} ({1})", - patent1.Title, patent1.YearOfPublication); - System.Console.WriteLine("{0} ({1})", - patent2.Title, patent1.YearOfPublication); - - Console.WriteLine(); - Console.WriteLine(patent1); - Console.WriteLine(patent2); - - Console.WriteLine(); - Console.WriteLine(patent3); - } - } -}