Skip to content
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
52 changes: 52 additions & 0 deletions .github/workflows/LocalesTest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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
4 changes: 2 additions & 2 deletions EssentialCSharp.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
Expand All @@ -12,8 +11,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\ChapterTests.props = src\ChapterTests.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}"
Expand Down
7 changes: 4 additions & 3 deletions src/Chapter02.Tests/Listing02.01.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter02.Listing02_01.Tests
{
Expand All @@ -8,9 +9,9 @@ public class LiteralValueTests
[TestMethod]
public void Main_WriteNumbers()
{
const string expected =
@"42
1.618034";
string expected =
$@"{42}
{1.618034}";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
Expand Down
2 changes: 1 addition & 1 deletion src/Chapter02.Tests/Listing02.02.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LiteralValueTests
[TestMethod]
public void Main_WriteNumbers()
{
const string expected = @"1.618033988749895";
string expected = $@"{1.618033988749895}";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
Expand Down
2 changes: 1 addition & 1 deletion src/Chapter02.Tests/Listing02.03.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LiteralValueTests
[TestMethod]
public void Main_WriteNumbers()
{
const string expected = @"1.6180339887498948";
string expected = $@"{1.6180339887498948M}";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
Expand Down
2 changes: 1 addition & 1 deletion src/Chapter02.Tests/Listing02.05.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class LiteralValueTests
[TestMethod]
public void Main_WriteNumbers()
{
const string expected = @"6.023E+23";
string expected = $@"{6.023E+23}";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
Expand Down
10 changes: 5 additions & 5 deletions src/Chapter02.Tests/Listing02.09.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public class ProgramTests
[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)
Expand Down
2 changes: 1 addition & 1 deletion src/Chapter04.Tests/Listing04.02.Negative.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ProgramTests
[TestMethod]
public void MainTest()
{
const string expected = @"-26457079712930.80";
string expected = $@"{-26457079712930.80M}";

IntelliTect.TestTools.Console.ConsoleAssert.Expect(
expected, Program.Main);
Expand Down
30 changes: 15 additions & 15 deletions src/Chapter04.Tests/Listing04.07.UnexpectedInequality.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ public class ProgramTests
[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)
Expand Down
7 changes: 3 additions & 4 deletions src/Chapter04.Tests/Listing04.24.WithCodeBlock.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ public class ProgramTests
[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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class ProgramTests
[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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public class ProgramTests
[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);
Expand Down
3 changes: 2 additions & 1 deletion src/Chapter04/Listing04.24.WithCodeBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public static void Main()

// 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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
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


[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 = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ProgramTests
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
Expand All @@ -19,7 +19,7 @@ public void MoreEnumerableMethodCalls()
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";
Expand Down
10 changes: 10 additions & 0 deletions testEnvironments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"version": "1",
"environments": [
{
"name": "WSL-Ubuntu",
"type": "wsl",
"wslDistribution": "Ubuntu"
}
]
}