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

feat: Write Tests for Table 3.01 #583

Merged
merged 2 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 72 additions & 5 deletions src/Chapter03.Tests/Table03.01.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,79 @@
using System.Diagnostics.CodeAnalysis;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_01.Tests;

[TestClass]
public class UppercaseTests
public class TupleDeclarationAndAssignmentTests
{
[NotNull]
public TestContext? TestContext { get; set; }
private readonly TupleDeclarationAndAssignment _sut = new();

[TestMethod]
public void AssignTupleToIndividuallyDeclaredVariables()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignTupleToIndividuallyDeclaredVariables);
}

[TestMethod]
public void AssignTupleToIndividuallyDeclaredVariablesThatArPreDeclared()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignTupleToIndividuallyDeclaredVariablesThatArPreDeclared);
}

[TestMethod]
public void AssignTupleToIndividuallyDeclaredAndImplicitlyTypedVariables()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignTupleToIndividuallyDeclaredAndImplicitlyTypedVariables);
}

[TestMethod]
public void AssignTupleToIndividuallyDeclaredVariablesThatImplicitlyTypedWithADistributiveSyntax()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignTupleToIndividuallyDeclaredVariablesThatImplicitlyTypedWithADistributiveSyntax);
}

[TestMethod]
public void DeclareANamedItemTupleAndAssignItTupleValuesAndThenAccessTheTupleItemsByName()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.DeclareANamedItemTupleAndAssignItTupleValuesAndThenAccessTheTupleItemsByName);
}

[TestMethod]
public void AssignANamedItemTupleToASingleImplicitlyTypedVariableThatIsImplicitlyTypedAndThenAccessTheTupleItemsByName()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignANamedItemTupleToASingleImplicitlyTypedVariableThatIsImplicitlyTypedAndThenAccessTheTupleItemsByName);
}

[TestMethod]
public void AssignAnUnnamedTupleToASingleImplicitlyTypedVariableAndThenAccessTheTupleElementsByTheirItemNumberProperty()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignAnUnnamedTupleToASingleImplicitlyTypedVariableAndThenAccessTheTupleElementsByTheirItemNumberProperty);
}

[TestMethod]
public void AssignANamedItemTupleToASingleImplicitlyTypedVariableAndThenAccessTheTupleItemsByTheirItemNumberProperty()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.AssignANamedItemTupleToASingleImplicitlyTypedVariableAndThenAccessTheTupleItemsByTheirItemNumberProperty);
}

[TestMethod]
public void TupleElementNamesCanBeInferredFromVariableAndPropertyNames()
{
string expected = $"The poorest country in the world in 2017 was Burundi, Bujumbura: {263.67}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(expected,
_sut.TupleElementNamesCanBeInferredFromVariableAndPropertyNames);
}
}
2 changes: 0 additions & 2 deletions src/Chapter03.Tests/Table03.03.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter03.Table03_03.Tests;
[TestClass]
public class ArrayHighlightsTests
{
public TestContext TestContext { get; set; } = null!; // Set by MSTest;

[TestMethod]
/* 1. */ [DataRow(".a", "CS0650")]
/* 2. */ [DataRow(".b", "CS1525", "CS1002", "CS1002", "CS1513", "CS1002", "CS1513", "CS1002")]
Expand Down
1 change: 0 additions & 1 deletion src/Chapter03/Table03.01.TupleDeclarationAndAssignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void AssignANamedItemTupleToASingleImplicitlyTypedVariableThatIsImplicitl
$@"The poorest country in the world in 2017 was {
countryInfo.Name}, {countryInfo.Capital}: {
countryInfo.GdpPerCapita}");

}

// 7.
Expand Down
Loading