-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task: added third example project featuring Temperature conversions u…
…sing new Double datatype support
- Loading branch information
Showing
15 changed files
with
541 additions
and
4 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
30 changes: 30 additions & 0 deletions
30
...temperature-units-of-measure/Acme.Temperature.UnitTests/Acme.Temperature.UnitTests.csproj
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,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageReference Include="Primitively.Abstractions" Version="1.5.0-alpha.14" /> | ||
<PackageReference Include="xunit" Version="2.7.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Acme.Temperature\Acme.Temperature.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
76 changes: 76 additions & 0 deletions
76
examples/03-temperature-units-of-measure/Acme.Temperature.UnitTests/CelsiusTests.cs
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,76 @@ | ||
namespace Acme.Temperature.UnitTests; | ||
|
||
public class CelsiusTests | ||
{ | ||
[Fact] | ||
public void AbsoluteZero_In_Sut_Scale_Converts_To_AbsoluteZero_In_Other_Scales() | ||
{ | ||
// Assign | ||
var celsius = Celsius.AbsoluteZero; | ||
|
||
// Act | ||
var fahrenheit = (Fahrenheit)celsius; | ||
var kelvin = (Kelvin)celsius; | ||
var rankine = (Rankine)celsius; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.AbsoluteZero); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.AbsoluteZero); | ||
kelvin.Should().BeEquivalentTo(Kelvin.AbsoluteZero); | ||
rankine.Should().BeEquivalentTo(Rankine.AbsoluteZero); | ||
} | ||
|
||
[Fact] | ||
public void WaterMeltingPoint_In_Sut_Scale_Converts_To_WaterMeltingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var celsius = Celsius.WaterMeltingPoint; | ||
|
||
// Act | ||
var fahrenheit = (Fahrenheit)celsius; | ||
var kelvin = (Kelvin)celsius; | ||
var rankine = (Rankine)celsius; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterMeltingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterMeltingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterMeltingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterMeltingPoint); | ||
} | ||
|
||
[Fact] | ||
public void WaterBoilingPoint_In_Sut_Scale_Converts_To_WaterBoilingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var celsius = Celsius.WaterBoilingPoint; | ||
|
||
// Act | ||
var fahrenheit = (Fahrenheit)celsius; | ||
var kelvin = (Kelvin)celsius; | ||
var rankine = (Rankine)celsius; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterBoilingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterBoilingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterBoilingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterBoilingPoint); | ||
} | ||
|
||
[Fact] | ||
public void Minimum_Sut_Scale_Converts_To_Minimum_In_Other_Scales() | ||
{ | ||
// Assign | ||
var celsius = new Celsius(Celsius.Minimum); | ||
|
||
// Act | ||
double kelvin = (Kelvin)celsius; | ||
double fahrenheit = (Fahrenheit)celsius; | ||
double rankine = (Rankine)celsius; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo((Celsius)Celsius.Minimum); | ||
fahrenheit.Should().Be(Fahrenheit.Minimum); | ||
kelvin.Should().Be(Kelvin.Minimum); | ||
rankine.Should().Be(Rankine.Minimum); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
examples/03-temperature-units-of-measure/Acme.Temperature.UnitTests/FahrenheitTests.cs
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,76 @@ | ||
namespace Acme.Temperature.UnitTests; | ||
|
||
public class FahrenheitTests | ||
{ | ||
[Fact] | ||
public void AbsoluteZero_In_Sut_Scale_Converts_To_AbsoluteZero_In_Other_Scales() | ||
{ | ||
// Assign | ||
var fahrenheit = Fahrenheit.AbsoluteZero; | ||
|
||
// Act | ||
var celsius = (Celsius)fahrenheit; | ||
var kelvin = (Kelvin)fahrenheit; | ||
var rankine = (Rankine)fahrenheit; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.AbsoluteZero); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.AbsoluteZero); | ||
kelvin.Should().BeEquivalentTo(Kelvin.AbsoluteZero); | ||
rankine.Should().BeEquivalentTo(Rankine.AbsoluteZero); | ||
} | ||
|
||
[Fact] | ||
public void WaterMeltingPoint_In_Sut_Scale_Converts_To_WaterMeltingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var fahrenheit = Fahrenheit.WaterMeltingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)fahrenheit; | ||
var kelvin = (Kelvin)fahrenheit; | ||
var rankine = (Rankine)fahrenheit; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterMeltingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterMeltingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterMeltingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterMeltingPoint); | ||
} | ||
|
||
[Fact] | ||
public void WaterBoilingPoint_In_Sut_Scale_Converts_To_WaterBoilingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var fahrenheit = Fahrenheit.WaterBoilingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)fahrenheit; | ||
var kelvin = (Kelvin)fahrenheit; | ||
var rankine = (Rankine)fahrenheit; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterBoilingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterBoilingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterBoilingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterBoilingPoint); | ||
} | ||
|
||
[Fact] | ||
public void Minimum_Sut_Scale_Converts_To_Minimum_In_Other_Scales() | ||
{ | ||
// Assign | ||
var fahrenheit = new Fahrenheit(Fahrenheit.Minimum); | ||
|
||
// Act | ||
double celsius = (Celsius)fahrenheit; | ||
double kelvin = (Kelvin)fahrenheit; | ||
double rankine = (Rankine)fahrenheit; | ||
|
||
// Assert | ||
celsius.Should().Be(Celsius.Minimum); | ||
fahrenheit.Should().BeEquivalentTo((Fahrenheit)Fahrenheit.Minimum); | ||
kelvin.Should().Be(Kelvin.Minimum); | ||
rankine.Should().Be(Rankine.Minimum); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
examples/03-temperature-units-of-measure/Acme.Temperature.UnitTests/GlobalUsings.cs
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,2 @@ | ||
global using Xunit; | ||
global using FluentAssertions; |
76 changes: 76 additions & 0 deletions
76
examples/03-temperature-units-of-measure/Acme.Temperature.UnitTests/KelvinTests.cs
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,76 @@ | ||
namespace Acme.Temperature.UnitTests; | ||
|
||
public class KelvinTests | ||
{ | ||
[Fact] | ||
public void AbsoluteZero_In_Sut_Scale_Converts_To_AbsoluteZero_In_Other_Scales() | ||
{ | ||
// Assign | ||
var kelvin = Kelvin.AbsoluteZero; | ||
|
||
// Act | ||
var celsius = (Celsius)kelvin; | ||
var fahrenheit = (Fahrenheit)kelvin; | ||
var rankine = (Rankine)kelvin; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.AbsoluteZero); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.AbsoluteZero); | ||
kelvin.Should().BeEquivalentTo(Kelvin.AbsoluteZero); | ||
rankine.Should().BeEquivalentTo(Rankine.AbsoluteZero); | ||
} | ||
|
||
[Fact] | ||
public void WaterMeltingPoint_In_Sut_Scale_Converts_To_WaterMeltingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var kelvin = Kelvin.WaterMeltingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)kelvin; | ||
var fahrenheit = (Fahrenheit)kelvin; | ||
var rankine = (Rankine)kelvin; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterMeltingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterMeltingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterMeltingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterMeltingPoint); | ||
} | ||
|
||
[Fact] | ||
public void WaterBoilingPoint_In_Sut_Scale_Converts_To_WaterBoilingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var kelvin = Kelvin.WaterBoilingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)kelvin; | ||
var fahrenheit = (Fahrenheit)kelvin; | ||
var rankine = (Rankine)kelvin; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterBoilingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterBoilingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterBoilingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterBoilingPoint); | ||
} | ||
|
||
[Fact] | ||
public void Minimum_Sut_Scale_Converts_To_Minimum_In_Other_Scales() | ||
{ | ||
// Assign | ||
var kelvin = new Kelvin(Kelvin.Minimum); | ||
|
||
// Act | ||
double celsius = (Celsius)kelvin; | ||
double fahrenheit = (Fahrenheit)kelvin; | ||
double rankine = (Rankine)kelvin; | ||
|
||
// Assert | ||
celsius.Should().Be(Celsius.Minimum); | ||
fahrenheit.Should().Be(Fahrenheit.Minimum); | ||
kelvin.Should().BeEquivalentTo((Kelvin)Kelvin.Minimum); | ||
rankine.Should().Be(Rankine.Minimum); | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
examples/03-temperature-units-of-measure/Acme.Temperature.UnitTests/RankineTests.cs
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,76 @@ | ||
namespace Acme.Temperature.UnitTests; | ||
|
||
public class RankineTests | ||
{ | ||
[Fact] | ||
public void AbsoluteZero_In_Sut_Scale_Converts_To_AbsoluteZero_In_Other_Scales() | ||
{ | ||
// Assign | ||
var rankine = Rankine.AbsoluteZero; | ||
|
||
// Act | ||
var celsius = (Celsius)rankine; | ||
var fahrenheit = (Fahrenheit)rankine; | ||
var kelvin = (Kelvin)rankine; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.AbsoluteZero); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.AbsoluteZero); | ||
kelvin.Should().BeEquivalentTo(Kelvin.AbsoluteZero); | ||
rankine.Should().BeEquivalentTo(Rankine.AbsoluteZero); | ||
} | ||
|
||
[Fact] | ||
public void WaterMeltingPoint_In_Sut_Scale_Converts_To_WaterMeltingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var rankine = Rankine.WaterMeltingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)rankine; | ||
var fahrenheit = (Fahrenheit)rankine; | ||
var kelvin = (Kelvin)rankine; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterMeltingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterMeltingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterMeltingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterMeltingPoint); | ||
} | ||
|
||
[Fact] | ||
public void WaterBoilingPoint_In_Sut_Scale_Converts_To_WaterBoilingPoint_In_Other_Scales() | ||
{ | ||
// Assign | ||
var rankine = Rankine.WaterBoilingPoint; | ||
|
||
// Act | ||
var celsius = (Celsius)rankine; | ||
var fahrenheit = (Fahrenheit)rankine; | ||
var kelvin = (Kelvin)rankine; | ||
|
||
// Assert | ||
celsius.Should().BeEquivalentTo(Celsius.WaterBoilingPoint); | ||
fahrenheit.Should().BeEquivalentTo(Fahrenheit.WaterBoilingPoint); | ||
kelvin.Should().BeEquivalentTo(Kelvin.WaterBoilingPoint); | ||
rankine.Should().BeEquivalentTo(Rankine.WaterBoilingPoint); | ||
} | ||
|
||
[Fact] | ||
public void Minimum_Sut_Scale_Converts_To_Minimum_In_Other_Scales() | ||
{ | ||
// Assign | ||
var rankine = new Rankine(Rankine.Minimum); | ||
|
||
// Act | ||
double celsius = (Celsius)rankine; | ||
double fahrenheit = (Fahrenheit)rankine; | ||
double kelvin = (Kelvin)rankine; | ||
|
||
// Assert | ||
celsius.Should().Be(Celsius.Minimum); | ||
fahrenheit.Should().Be(Fahrenheit.Minimum); | ||
kelvin.Should().Be(Kelvin.Minimum); | ||
rankine.Should().BeEquivalentTo((Rankine)Rankine.Minimum); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/03-temperature-units-of-measure/Acme.Temperature/Acme.Temperature.csproj
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Primitively" Version="1.5.0-alpha.14" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.