-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests for Listings 04,05,06,08,09,16,17,20,22,23,26,28,31,32,33,34,39,40,42,43,45,47,48,49,50,52,53 * Remove extra space from Listing04.22 * Update Listing04.26 signature, and remove return * Change Listing4.31 prop from object[] to string * Make Listing04.49 ValidateAndMove public * Make Listing04.53 public. Improve tests 49 execution. * Use NumberFormatInfo to get culture for Infinity symbols
- Loading branch information
Showing
32 changed files
with
796 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_04.Tests | ||
{ | ||
[TestClass] | ||
public class FortyTwoTests | ||
{ | ||
[TestMethod] | ||
public void Main_AdditionOperatorWithNonNumericType_StringConcatenated() | ||
{ | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_05.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_UseCharInArithmeticOperation_PrintCharacter() | ||
{ | ||
const string expected = | ||
@"g"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_06.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_CharacterDistanceBetweenTwoCharacters_WriteIntegerDistance() | ||
{ | ||
const string expected = | ||
@"3"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_08.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_DivideFloatBy0_WriteNaN() | ||
{ | ||
const string expected = | ||
@"NaN"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Globalization; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_09.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_OverflowBoundsOfFloat_WriteInfinity() | ||
{ | ||
string expected = $"-{NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}\n" + | ||
$"{NumberFormatInfo.CurrentInfo.PositiveInfinitySymbol}"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_16.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_PostIncrementInteger_ResultNotIncremented() | ||
{ | ||
const string expected = | ||
@"result = 123 and count = 124"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_17.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_PreIncrementInteger_ResultIsIncremented() | ||
{ | ||
const string expected = | ||
@"result = 124 and count = 124"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using IntelliTect.TestTools.Console; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_20.Tests | ||
{ | ||
[TestClass] | ||
public class TicTacToeTests | ||
{ | ||
[TestMethod] | ||
public void Main_Enter1TryToPlayAgainstComputer_ComputerPathSelected() | ||
{ | ||
const string expected = | ||
@"1 - Play against the computer | ||
2 - Play against another player. | ||
Choose:<<1 | ||
>>Play against computer selected."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, TicTacToe.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_Enter2TryToPlayAgainstOtherPerson_TwoPlayerPathSelected() | ||
{ | ||
const string expected = | ||
@"1 - Play against the computer | ||
2 - Play against another player. | ||
Choose:<<2 | ||
>>Play against another player."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, TicTacToe.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_EnterOther_TwoPlayerPathSelected() | ||
{ | ||
const string expected = | ||
@"1 - Play against the computer | ||
2 - Play against another player. | ||
Choose:<<9 | ||
>>Play against another player."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, TicTacToe.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using IntelliTect.TestTools.Console; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_22.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_InputOfNegative1_Exit() | ||
{ | ||
Program.input = -1; | ||
|
||
const string expected = | ||
@"Exiting..."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_Input10_AnswerTooHigh() | ||
{ | ||
Program.input = 10; | ||
|
||
const string expected = | ||
@"Tic-tac-toe has less than 10 maximum turns."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_Input5_AnswerTooLow() | ||
{ | ||
Program.input = 5; | ||
|
||
const string expected = | ||
@"Tic-tac-toe has more than 5 maximum turns."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_Input9_CorrectAnswer() | ||
{ | ||
Program.input = 9; | ||
|
||
const string expected = | ||
@"Correct, tic-tac-toe has a maximum of 9 turns."; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using IntelliTect.TestTools.Console; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_23.Tests | ||
{ | ||
[TestClass] | ||
public class Listing04_23_Tests | ||
{ | ||
[TestMethod] | ||
public void Main_Input8_ExitProgram() | ||
{ | ||
Program.input = 8; | ||
|
||
const string expected = | ||
@"Exiting"; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_Input10_ProgramDoesNotExit() | ||
{ | ||
Program.input = 10; | ||
|
||
const string expected = | ||
""; | ||
|
||
ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26.Tests | ||
{ | ||
[TestClass] | ||
public class LeveragingTryParseTests | ||
{ | ||
public static int OutValue = 0; | ||
|
||
[TestMethod] | ||
public void Main_InputNameAndAge35_AgeProperlyParsed() | ||
{ | ||
const string expected = | ||
@"Enter your first name: <<Inigo | ||
>>Enter your age: <<35 | ||
>>Hi Inigo! You are 420 months old."; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected, | ||
LeveragingTryParse.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_InputNameAndAgeThirtyFive_AgeNotParsed() | ||
{ | ||
const string expected = | ||
@"Enter your first name: <<Inigo | ||
>>Enter your age: <<ThirtyFive | ||
>>The age entered ,ThirtyFive, is not valid."; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, LeveragingTryParse.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_28.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_Input5_BooleanConditionHit() | ||
{ | ||
const string expected = | ||
@"Tic-tac-toe has more than 5 maximum turns."; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_31.Tests | ||
{ | ||
[TestClass] | ||
public class ProgramTests | ||
{ | ||
[TestMethod] | ||
public void Main_InputIsEmpty_PlayerQuitConditionHit() | ||
{ | ||
Program.input = ""; | ||
Program.currentPlayer = "Inigo"; | ||
|
||
const string expected = | ||
@"Player Inigo quit!!"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
|
||
[TestMethod] | ||
public void Main_InputIsQuit_PlayerQuitConditionHit() | ||
{ | ||
Program.input = "quit"; | ||
Program.currentPlayer = "Inigo"; | ||
|
||
const string expected = | ||
@"Player Inigo quit!!"; | ||
|
||
IntelliTect.TestTools.Console.ConsoleAssert.Expect( | ||
expected, Program.Main); | ||
} | ||
} | ||
} |
Oops, something went wrong.