From b021395bc2b1d0492eac251439ec2b855e8c8298 Mon Sep 17 00:00:00 2001 From: Stuart Blackburn Date: Wed, 3 Apr 2024 03:54:02 +0100 Subject: [PATCH] task: added unit tests for new Double and Single floating-point types --- test/Acme.TestLib/Temperature.cs | 71 ----------------- test/Acme.TestLib2/Acme.TestLib2.csproj | 4 + test/Acme.TestLib2/Double/Celsius.cs | 20 +++++ test/Acme.TestLib2/Double/Fahrenheit.cs | 20 +++++ test/Acme.TestLib2/Double/Kelvin.cs | 20 +++++ test/Acme.TestLib2/Double/Rankine.cs | 20 +++++ test/Acme.TestLib2/ITemperature.cs | 10 +++ test/Acme.TestLib2/Single/Celsius.cs | 20 +++++ test/Acme.TestLib2/Single/Fahrenheit.cs | 20 +++++ test/Acme.TestLib2/Single/Kelvin.cs | 20 +++++ test/Acme.TestLib2/Single/Rankine.cs | 20 +++++ .../NumericTests/Double/CelsiusTests.cs | 78 +++++++++++++++++++ .../NumericTests/Double/FahrenheitTests.cs | 78 +++++++++++++++++++ .../NumericTests/Double/GlobalUsings.cs | 2 + .../NumericTests/Double/KelvinTests.cs | 78 +++++++++++++++++++ .../NumericTests/Double/RankineTests.cs | 78 +++++++++++++++++++ .../NumericTests/Single/CelsiusTests.cs | 78 +++++++++++++++++++ .../NumericTests/Single/FahrenheitTests.cs | 78 +++++++++++++++++++ .../NumericTests/Single/KelvinTests.cs | 78 +++++++++++++++++++ .../NumericTests/Single/RankineTests.cs | 78 +++++++++++++++++++ 20 files changed, 800 insertions(+), 71 deletions(-) delete mode 100644 test/Acme.TestLib/Temperature.cs create mode 100644 test/Acme.TestLib2/Double/Celsius.cs create mode 100644 test/Acme.TestLib2/Double/Fahrenheit.cs create mode 100644 test/Acme.TestLib2/Double/Kelvin.cs create mode 100644 test/Acme.TestLib2/Double/Rankine.cs create mode 100644 test/Acme.TestLib2/ITemperature.cs create mode 100644 test/Acme.TestLib2/Single/Celsius.cs create mode 100644 test/Acme.TestLib2/Single/Fahrenheit.cs create mode 100644 test/Acme.TestLib2/Single/Kelvin.cs create mode 100644 test/Acme.TestLib2/Single/Rankine.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Double/CelsiusTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Double/FahrenheitTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Double/GlobalUsings.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Double/KelvinTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Double/RankineTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Single/CelsiusTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Single/FahrenheitTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Single/KelvinTests.cs create mode 100644 test/Primitively.IntegrationTests/NumericTests/Single/RankineTests.cs diff --git a/test/Acme.TestLib/Temperature.cs b/test/Acme.TestLib/Temperature.cs deleted file mode 100644 index 3710a40..0000000 --- a/test/Acme.TestLib/Temperature.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Primitively; - -// https://en.wikipedia.org/wiki/Celsius -// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature - -namespace Acme.TestLib; - -[Double(2, Minimum = -273.15d)] -public partial record struct Celsius : ITemperature -{ - public static Celsius AbsoluteZero => new(-273.15d); - - public static Celsius WaterMeltingPoint => new(0d); - - public static Celsius WaterBoilingPoint => new(99.9839d); - - public static explicit operator Kelvin(Celsius value) => new(value + 273.15d); - public static explicit operator Fahrenheit(Celsius value) => new((9d / 5d * value) + 32d); - public static explicit operator Rankine(Celsius value) => new((value + 273.15d) * (9d / 5d)); -} - -[Double(Minimum = -459.67d)] -public partial record struct Fahrenheit : ITemperature -{ - public static Fahrenheit AbsoluteZero => new(-459.67d); - - public static Fahrenheit WaterMeltingPoint => new(32d); - - public static Fahrenheit WaterBoilingPoint => new(211.97102d); - - public static explicit operator Celsius(Fahrenheit value) => new((value - 32d) * (5d / 9d)); - public static explicit operator Kelvin(Fahrenheit value) => new((value + 459.67d) * (5d / 9d)); - public static explicit operator Rankine(Fahrenheit value) => new(value + 459.67d); -} - -[Double(Minimum = 0d)] -public partial record struct Kelvin : ITemperature -{ - public static Kelvin AbsoluteZero => new(0d); - - public static Kelvin WaterMeltingPoint => new(273.15d); - - public static Kelvin WaterBoilingPoint => new(373.1339d); - - public static explicit operator Celsius(Kelvin value) => new(value - 273.15d); - public static explicit operator Fahrenheit(Kelvin value) => new((9d / 5d * value) - 459.67d); - public static explicit operator Rankine(Kelvin value) => new(9d / 5d * value); -} - -[Double(Minimum = 0d)] -public partial record struct Rankine : ITemperature -{ - public static Rankine AbsoluteZero => new(0d); - - public static Rankine WaterMeltingPoint => new(491.67d); - - public static Rankine WaterBoilingPoint => new(671.64102d); - - public static explicit operator Celsius(Rankine value) => new((5d / 9d * value) - 273.15d); - public static explicit operator Fahrenheit(Rankine value) => new(value - 459.67d); - public static explicit operator Kelvin(Rankine value) => new(5d / 9d * value); -} - -public interface ITemperature where T : ITemperature -{ -#if NET7_0_OR_GREATER - static abstract T AbsoluteZero { get; } - static abstract T WaterMeltingPoint { get; } - static abstract T WaterBoilingPoint { get; } -#endif -} diff --git a/test/Acme.TestLib2/Acme.TestLib2.csproj b/test/Acme.TestLib2/Acme.TestLib2.csproj index 37ebcd1..4d481da 100644 --- a/test/Acme.TestLib2/Acme.TestLib2.csproj +++ b/test/Acme.TestLib2/Acme.TestLib2.csproj @@ -21,4 +21,8 @@ + + + + diff --git a/test/Acme.TestLib2/Double/Celsius.cs b/test/Acme.TestLib2/Double/Celsius.cs new file mode 100644 index 0000000..b795ccb --- /dev/null +++ b/test/Acme.TestLib2/Double/Celsius.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipedia.org/wiki/Celsius +// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Double; + +[Double(2, Minimum = -273.15d)] +public partial record struct Celsius : ITemperature +{ + public static Celsius AbsoluteZero => new(-273.15d); + + public static Celsius WaterMeltingPoint => new(0d); + + public static Celsius WaterBoilingPoint => new(99.9839d); + + public static explicit operator Kelvin(Celsius value) => new(value + 273.15d); + public static explicit operator Fahrenheit(Celsius value) => new((value * (9d / 5d)) + 32d); + public static explicit operator Rankine(Celsius value) => new((value + 273.15d) * (9d / 5d)); +} diff --git a/test/Acme.TestLib2/Double/Fahrenheit.cs b/test/Acme.TestLib2/Double/Fahrenheit.cs new file mode 100644 index 0000000..06dcfa4 --- /dev/null +++ b/test/Acme.TestLib2/Double/Fahrenheit.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipedia.org/wiki/Celsius +// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Double; + +[Double(2, Minimum = -459.67d)] +public partial record struct Fahrenheit : ITemperature +{ + public static Fahrenheit AbsoluteZero => new(-459.67d); + + public static Fahrenheit WaterMeltingPoint => new(32d); + + public static Fahrenheit WaterBoilingPoint => new(211.97102d); + + public static explicit operator Celsius(Fahrenheit value) => new((value - 32d) * (5d / 9d)); + public static explicit operator Kelvin(Fahrenheit value) => new((value + 459.67d) * (5d / 9d)); + public static explicit operator Rankine(Fahrenheit value) => new(value + 459.67d); +} diff --git a/test/Acme.TestLib2/Double/Kelvin.cs b/test/Acme.TestLib2/Double/Kelvin.cs new file mode 100644 index 0000000..553cebe --- /dev/null +++ b/test/Acme.TestLib2/Double/Kelvin.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipedia.org/wiki/Celsius +// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Double; + +[Double(2, Minimum = 0d)] +public partial record struct Kelvin : ITemperature +{ + public static Kelvin AbsoluteZero => new(0d); + + public static Kelvin WaterMeltingPoint => new(273.15d); + + public static Kelvin WaterBoilingPoint => new(373.1339d); + + public static explicit operator Celsius(Kelvin value) => new(value - 273.15d); + public static explicit operator Fahrenheit(Kelvin value) => new((9d / 5d * value) - 459.67d); + public static explicit operator Rankine(Kelvin value) => new(9d / 5d * value); +} diff --git a/test/Acme.TestLib2/Double/Rankine.cs b/test/Acme.TestLib2/Double/Rankine.cs new file mode 100644 index 0000000..8e21571 --- /dev/null +++ b/test/Acme.TestLib2/Double/Rankine.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipedia.org/wiki/Celsius +// https://en.wikipedia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Double; + +[Double(2, Minimum = 0d)] +public partial record struct Rankine : ITemperature +{ + public static Rankine AbsoluteZero => new(0d); + + public static Rankine WaterMeltingPoint => new(491.67d); + + public static Rankine WaterBoilingPoint => new(671.64102d); + + public static explicit operator Celsius(Rankine value) => new((5d / 9d * value) - 273.15d); + public static explicit operator Fahrenheit(Rankine value) => new(value - 459.67d); + public static explicit operator Kelvin(Rankine value) => new(5d / 9d * value); +} diff --git a/test/Acme.TestLib2/ITemperature.cs b/test/Acme.TestLib2/ITemperature.cs new file mode 100644 index 0000000..247a9ef --- /dev/null +++ b/test/Acme.TestLib2/ITemperature.cs @@ -0,0 +1,10 @@ +namespace Acme.TestLib2; + +public interface ITemperature where T : ITemperature +{ +#if NET7_0_OR_GREATER + static abstract T AbsoluteZero { get; } + static abstract T WaterMeltingPoint { get; } + static abstract T WaterBoilingPoint { get; } +#endif +} diff --git a/test/Acme.TestLib2/Single/Celsius.cs b/test/Acme.TestLib2/Single/Celsius.cs new file mode 100644 index 0000000..7b8f077 --- /dev/null +++ b/test/Acme.TestLib2/Single/Celsius.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipefia.org/wiki/Celsius +// https://en.wikipefia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Single; + +[Single(2, Minimum = -273.15f)] +public partial record struct Celsius : ITemperature +{ + public static Celsius AbsoluteZero => new(-273.15f); + + public static Celsius WaterMeltingPoint => new(0f); + + public static Celsius WaterBoilingPoint => new(99.9839f); + + public static explicit operator Kelvin(Celsius value) => new(value + 273.15f); + public static explicit operator Fahrenheit(Celsius value) => new((value * (9f / 5f)) + 32f); + public static explicit operator Rankine(Celsius value) => new((value + 273.15f) * (9f / 5f)); +} diff --git a/test/Acme.TestLib2/Single/Fahrenheit.cs b/test/Acme.TestLib2/Single/Fahrenheit.cs new file mode 100644 index 0000000..fdb1919 --- /dev/null +++ b/test/Acme.TestLib2/Single/Fahrenheit.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipefia.org/wiki/Celsius +// https://en.wikipefia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Single; + +[Single(2, Minimum = -459.67f)] +public partial record struct Fahrenheit : ITemperature +{ + public static Fahrenheit AbsoluteZero => new(-459.67f); + + public static Fahrenheit WaterMeltingPoint => new(32f); + + public static Fahrenheit WaterBoilingPoint => new(211.97102f); + + public static explicit operator Celsius(Fahrenheit value) => new((value - 32f) * (5f / 9f)); + public static explicit operator Kelvin(Fahrenheit value) => new((value + 459.67f) * (5f / 9f)); + public static explicit operator Rankine(Fahrenheit value) => new(value + 459.67f); +} diff --git a/test/Acme.TestLib2/Single/Kelvin.cs b/test/Acme.TestLib2/Single/Kelvin.cs new file mode 100644 index 0000000..13cc2b7 --- /dev/null +++ b/test/Acme.TestLib2/Single/Kelvin.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipefia.org/wiki/Celsius +// https://en.wikipefia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Single; + +[Single(2, Minimum = 0f)] +public partial record struct Kelvin : ITemperature +{ + public static Kelvin AbsoluteZero => new(0f); + + public static Kelvin WaterMeltingPoint => new(273.15f); + + public static Kelvin WaterBoilingPoint => new(373.1339f); + + public static explicit operator Celsius(Kelvin value) => new(value - 273.15f); + public static explicit operator Fahrenheit(Kelvin value) => new((9f / 5f * value) - 459.67f); + public static explicit operator Rankine(Kelvin value) => new(9f / 5f * value); +} diff --git a/test/Acme.TestLib2/Single/Rankine.cs b/test/Acme.TestLib2/Single/Rankine.cs new file mode 100644 index 0000000..60613e7 --- /dev/null +++ b/test/Acme.TestLib2/Single/Rankine.cs @@ -0,0 +1,20 @@ +using Primitively; + +// https://en.wikipefia.org/wiki/Celsius +// https://en.wikipefia.org/wiki/Conversion_of_scales_of_temperature + +namespace Acme.TestLib2.Single; + +[Single(2, Minimum = 0f)] +public partial record struct Rankine : ITemperature +{ + public static Rankine AbsoluteZero => new(0f); + + public static Rankine WaterMeltingPoint => new(491.67f); + + public static Rankine WaterBoilingPoint => new(671.64102f); + + public static explicit operator Celsius(Rankine value) => new((5f / 9f * value) - 273.15f); + public static explicit operator Fahrenheit(Rankine value) => new(value - 459.67f); + public static explicit operator Kelvin(Rankine value) => new(5f / 9f * value); +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Double/CelsiusTests.cs b/test/Primitively.IntegrationTests/NumericTests/Double/CelsiusTests.cs new file mode 100644 index 0000000..ed833d9 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Double/CelsiusTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Double; + +namespace Primitively.IntegrationTests.NumericTests.Double; + +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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Double/FahrenheitTests.cs b/test/Primitively.IntegrationTests/NumericTests/Double/FahrenheitTests.cs new file mode 100644 index 0000000..2a9367b --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Double/FahrenheitTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Double; + +namespace Primitively.IntegrationTests.NumericTests.Double; + +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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Double/GlobalUsings.cs b/test/Primitively.IntegrationTests/NumericTests/Double/GlobalUsings.cs new file mode 100644 index 0000000..30b9735 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Double/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using Xunit; +global using FluentAssertions; diff --git a/test/Primitively.IntegrationTests/NumericTests/Double/KelvinTests.cs b/test/Primitively.IntegrationTests/NumericTests/Double/KelvinTests.cs new file mode 100644 index 0000000..d7852e3 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Double/KelvinTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Single; + +namespace Primitively.IntegrationTests.NumericTests.Single; + +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 + float celsius = (Celsius)kelvin; + float fahrenheit = (Fahrenheit)kelvin; + float 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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Double/RankineTests.cs b/test/Primitively.IntegrationTests/NumericTests/Double/RankineTests.cs new file mode 100644 index 0000000..91db66b --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Double/RankineTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Single; + +namespace Primitively.IntegrationTests.NumericTests.Single; + +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 + float celsius = (Celsius)rankine; + float fahrenheit = (Fahrenheit)rankine; + float 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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Single/CelsiusTests.cs b/test/Primitively.IntegrationTests/NumericTests/Single/CelsiusTests.cs new file mode 100644 index 0000000..4597282 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Single/CelsiusTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Single; + +namespace Primitively.IntegrationTests.NumericTests.Single; + +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 + float kelvin = (Kelvin)celsius; + float fahrenheit = (Fahrenheit)celsius; + float 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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Single/FahrenheitTests.cs b/test/Primitively.IntegrationTests/NumericTests/Single/FahrenheitTests.cs new file mode 100644 index 0000000..712d7c9 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Single/FahrenheitTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Single; + +namespace Primitively.IntegrationTests.NumericTests.Single; + +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 + float celsius = (Celsius)fahrenheit; + float kelvin = (Kelvin)fahrenheit; + float 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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Single/KelvinTests.cs b/test/Primitively.IntegrationTests/NumericTests/Single/KelvinTests.cs new file mode 100644 index 0000000..f22ff62 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Single/KelvinTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Double; + +namespace Primitively.IntegrationTests.NumericTests.Double; + +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); + } +} diff --git a/test/Primitively.IntegrationTests/NumericTests/Single/RankineTests.cs b/test/Primitively.IntegrationTests/NumericTests/Single/RankineTests.cs new file mode 100644 index 0000000..5d03ba6 --- /dev/null +++ b/test/Primitively.IntegrationTests/NumericTests/Single/RankineTests.cs @@ -0,0 +1,78 @@ +using Acme.TestLib2.Double; + +namespace Primitively.IntegrationTests.NumericTests.Double; + +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); + } +}