Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests chapter04 v8 #78

Merged
merged 11 commits into from
Jul 25, 2019
19 changes: 19 additions & 0 deletions src/Chapter04.Tests/Listing04.04.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.05.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.06.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.08.Tests.cs
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);
}
}
}
19 changes: 19 additions & 0 deletions src/Chapter04.Tests/Listing04.09.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.16.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.17.Tests.cs
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);
}
}
}
48 changes: 48 additions & 0 deletions src/Chapter04.Tests/Listing04.20.Tests.cs
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);
}
}
}
57 changes: 57 additions & 0 deletions src/Chapter04.Tests/Listing04.22.Tests.cs
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);
}
}
}
33 changes: 33 additions & 0 deletions src/Chapter04.Tests/Listing04.23.Tests.cs
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);
}
}
}
34 changes: 34 additions & 0 deletions src/Chapter04.Tests/Listing04.26.Tests.cs
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);
}
}
}
18 changes: 18 additions & 0 deletions src/Chapter04.Tests/Listing04.28.Tests.cs
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);
}
}
}
34 changes: 34 additions & 0 deletions src/Chapter04.Tests/Listing04.31.Tests.cs
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);
}
}
}
Loading