Test against different locales
ADD
.github/workflows/LocalesTest.yml
+name: Test Different Locales
+
+on:
+ push:
+ branches: [ v9.0 ]
+ pull_request:
+ branches: [ v9.0 ]
+
+jobs:
+ set-build-and-test-locale-languages:
+ name: Build and Test ${{ matrix.locale-lang }} Locale On Ubuntu
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ locale-lang: ["pt_BR.UTF-8", "fr_FR.UTF-8"]
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup dotnet SDK
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: |
+ 3.1.x
+ 5.x
+ 6.x
+ - name: Get Build Information
+ run: |
+ pwd
+ dotnet --info
+ dotnet --version
+ - name: SetLocale To ${{ matrix.locale-lang }}, and Build and Test
+ run: |
+ sudo locale-gen ${{ matrix.locale-lang }}
+ sudo localectl set-locale LANG=${{ matrix.locale-lang }}
+ LANG=${{ matrix.locale-lang }}
+ export LANG=${{ matrix.locale-lang }}
+ sudo update-locale LANG=${{ matrix.locale-lang }}
+ echo Current Locale Settings:
+ echo Run locale to get the information about the current locale and language settings:
+ locale
+ echo Run locale -a to list all enabled locales:
+ locale -a
+ echo Run localectl status to find system locale status.
+ localectl status
+ echo Visual Test
+ echo "Printing date"
+ date
+ echo Restore dependencies
+ dotnet restore
+ echo Build
+ dotnet build --no-restore
+ echo Test
+ dotnet test --no-build --no-restore --verbosity normal

MODIFY
EssentialCSharp.sln
EssentialCSharp.sln
-
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
@@ -13,8 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Common.props = Common.props
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
- README.md = README.md
global.json = global.json
+ README.md = README.md
+ testEnvironments.json = testEnvironments.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{91698F73-19EB-4531-980C-5B8B76DC28C9}"

MODIFY
src/Chapter02.Tests/Listing02.01.Tests.cs
src/Chapter02.Tests/Listing02.01.Tests.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_01.Tests
{
@@ -8,9 +9,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_01.Tests
[TestMethod]
public void Main_WriteNumbers()
{
- const string expected =
-@"42
-1.618034";
+ string expected =
+ $@"{42}
+{1.618034}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter02.Tests/Listing02.02.Tests.cs
src/Chapter02.Tests/Listing02.02.Tests.cs
@@ -8,7 +8,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_02.Tests
[TestMethod]
public void Main_WriteNumbers()
{
- const string expected = @"1.618033988749895";
+ string expected = $@"{1.618033988749895}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter02.Tests/Listing02.03.Tests.cs
src/Chapter02.Tests/Listing02.03.Tests.cs
@@ -8,7 +8,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_03.Tests
[TestMethod]
public void Main_WriteNumbers()
{
- const string expected = @"1.6180339887498948";
+ string expected = $@"{1.6180339887498948M}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter02.Tests/Listing02.05.Tests.cs
src/Chapter02.Tests/Listing02.05.Tests.cs
@@ -8,7 +8,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_05.Tests
[TestMethod]
public void Main_WriteNumbers()
{
- const string expected = @"6.023E+23";
+ string expected = $@"{6.023E+23}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter02.Tests/Listing02.09.Tests.cs
src/Chapter02.Tests/Listing02.09.Tests.cs
@@ -9,13 +9,13 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_09.Tests
[TestMethod]
public void Main_WriteBooleanStatements()
{
- const string netCoreApp2expected =
-@"False: 1.61803398874989 == 1.61803398874989
-True: 1.61803398874989 == 1.61803398874989";
+ string netCoreApp2expected =
+$@"False: {1.61803398874989} == {1.61803398874989}
+True: {1.61803398874989} == {1.61803398874989}";
string expected = // netcoreapp3.0 and later
-@"True: 1.618033988749895 == 1.618033988749895
-True: 1.618033988749895 == 1.618033988749895";
+$@"True: {1.618033988749895} == {1.618033988749895}
+True: {1.618033988749895} == {1.618033988749895}";
string netCoreVersion = NetCore.GetNetCoreVersion();
if (string.Compare(netCoreVersion, "3")<0)

MODIFY
src/Chapter04.Tests/Listing04.02.Negative.Tests.cs
src/Chapter04.Tests/Listing04.02.Negative.Tests.cs
@@ -8,7 +8,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_02.Tests
[TestMethod]
public void MainTest()
{
- const string expected = @"-26457079712930.80";
+ string expected = $@"{-26457079712930.80M}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04.Tests/Listing04.07.UnexpectedInequality.Tests.cs
src/Chapter04.Tests/Listing04.07.UnexpectedInequality.Tests.cs
@@ -9,23 +9,23 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_07.Tests
[TestMethod]
public void MainTest()
{
- const string netCoreApp3expected =
-@"4.2 != 4.2000002861023
-4.2 != 4.20000028610229
-(float)4.2M != 4.2F
-4.20000028610229 != 4.2
-4.2F != 4.2D
-4.19999980926514 != 4.2
-4.2F != 4.2D";
+ string netCoreApp3expected =
+$@"{4.2D} != {4.2000002861023D}
+{4.2} != {4.20000028610229}
+(float){4.2F}M != {4.2F}F
+{4.20000028610229} != {4.2}
+{4.2F}F != {4.2D}D
+{4.19999980926514D} != {4.2D}
+{4.2F}F != {4.2D}D";
string expected =
- @"4.2 != 4.2000002861023
-4.2 != 4.200000286102295
-(float)4.2M != 4.2000003F
-4.200000286102295 != 4.2
-4.2000003F != 4.2D
-4.199999809265137 != 4.2
-4.2F != 4.2D";
+ $@"{4.2D} != {4.2000002861023D}
+{4.2} != {4.200000286102295}
+(float){4.2F}M != {4.2000003F}F
+{4.200000286102295} != {4.2}
+{4.2000003F}F != {4.2}D
+{4.199999809265137D} != {4.2D}
+{4.2F}F != {4.2D}D";
string netCoreVersion = NetCore.GetNetCoreVersion();
if (string.Compare(netCoreVersion, "3") < 0)

MODIFY
src/Chapter04.Tests/Listing04.24.WithCodeBlock.Tests.cs
src/Chapter04.Tests/Listing04.24.WithCodeBlock.Tests.cs
@@ -8,10 +8,9 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_24.Tests
[TestMethod]
public void MainTest()
{
- const string expected =
-@"Enter the radius of the circle: <<3
->>The area of the circle is: 28.27";
-
+ string expected =
+$@"Enter the radius of the circle: <<3
+>>The area of the circle is: {28.27}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, CircleAreaCalculator.Main);
}

MODIFY
src/Chapter04.Tests/Listing04.25.RelyingOnIndentation.Tests.cs
src/Chapter04.Tests/Listing04.25.RelyingOnIndentation.Tests.cs
@@ -8,8 +8,8 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_25.Tests
[TestMethod]
public void MainTest()
{
- const string expected =
-@"The area of the circle is: 0.00";
+ string expected =
+$@"The area of the circle is: {0.00M}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04.Tests/Listing04.26.IdenticalInFunctionality.Tests.cs
src/Chapter04.Tests/Listing04.26.IdenticalInFunctionality.Tests.cs
@@ -8,8 +8,8 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_26.Tests
[TestMethod]
public void MainTest()
{
- const string expected =
-@"The area of the circle is: 0.00";
+ string expected =
+$@"The area of the circle is: {0.00M}";
IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);

MODIFY
src/Chapter04/Listing04.24.WithCodeBlock.cs
src/Chapter04/Listing04.24.WithCodeBlock.cs
@@ -16,7 +16,8 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter04.Listing04_24
// double.Parse converts the ReadLine()
// return to a double
- radius = double.Parse(System.Console.ReadLine());
+ string temp = System.Console.ReadLine();
+ radius = double.Parse(temp);
if(radius >= 0)
#region HIGHLIGHT
{

RENAME
src/Chapter09.Tests/Listing09.ReadOnlyMembers.Tests.cs
src/Chapter09.Tests/Listing09.02.ReadOnlyMembers.Tests.cs
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Threading.Tasks;
-namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09.Tests
+namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09_02.Tests
{
// Use keyword struct to declare a value type
@@ -10,7 +10,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter09.Listing09.Tests
[TestClass]
public class MyTestClass
{
- [TestMethod]// [Ignore("WIP: Currently an error is not reported when one is expected.")]
+ [TestMethod]
async public Task ReadOnlyMethod_ModifyObject_ErrorReported()
{
string thingCode = @"

MODIFY
src/Chapter15.Tests/Listing15.25.MoreSystem.Linq.EnumerableMethodCalls.Tests.cs
src/Chapter15.Tests/Listing15.25.MoreSystem.Linq.EnumerableMethodCalls.Tests.cs
@@ -9,7 +9,7 @@ namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter15.Listing15_25.Tests
public void MoreEnumerableMethodCalls()
{
string expected =
-@"Stuff: System.Object, 1, 3, 5, 7, 9, ""thing"", ????????-????-????-????-????????????
+$@"Stuff: System.Object, 1, 3, 5, 7, 9, ""thing"", ????????-????-????-????-????????????
Even integers: 0, 2, 4, 6, 8
Odd integers: 1, 3, 5, 7, 9
Union of odd and even: 0, 2, 4, 6, 8, 1, 3, 5, 7, 9
@@ -19,7 +19,7 @@ Intersection with even: 0, 2, 4, 6, 8
Distinct: 0, 2, 4, 6, 8, 1, 3, 5, 7, 9
Collection ""SequenceEquals"" numbers.Concat(odd).Distinct())
Reverse: 9, 7, 5, 3, 1, 8, 6, 4, 2, 0
-Average: 4.5
+Average: {4.5}
Sum: 45
Max: 9
Min: 0";

Test against different locales (#320)