/// <summary>
 /// Converts the Double input to the correct double value.
 /// </summary>
 /// <typeparam name="TInput"> The temperature type to be converted to. </typeparam>
 /// <param name="input"> The value to be converted. </param>
 /// <exception cref="ArgumentException"> The TInput type is not a valid type for this method. </exception>
 /// <returns>
 /// The result of the conversion.
 /// </returns>
 public static double To <TInput>(this DoubleBase input)
     where TInput : TemperatureBase
 {
     return(typeof(TInput).Name switch
     {
         nameof(Celsius) when input is CelsiusDouble castInput => CelsiusConverter.CelsiusToCelsius(castInput.Temperature),
         nameof(Celsius) when input is FahrenheitDouble castInput => FahrenheitConverter.FahrenheitToCelsius(castInput.Temperature),
         nameof(Celsius) when input is KelvinDouble castInput => KelvinConverter.KelvinToCelsius(castInput.Temperature),
         nameof(Celsius) when input is GasDouble castInput => GasConverter.GasToCelsius(castInput.Temperature),
         nameof(Celsius) when input is RankineDouble castInput => RankineConverter.RankineToCelsius(castInput.Temperature),
         nameof(Fahrenheit) when input is CelsiusDouble castInput => CelsiusConverter.CelsiusToFahrenheit(castInput.Temperature),
         nameof(Fahrenheit) when input is FahrenheitDouble castInput => FahrenheitConverter.FahrenheitToFahrenheit(castInput.Temperature),
         nameof(Fahrenheit) when input is KelvinDouble castInput => KelvinConverter.KelvinToFahrenheit(castInput.Temperature),
         nameof(Fahrenheit) when input is GasDouble castInput => GasConverter.GasToFahrenheit(castInput.Temperature),
         nameof(Fahrenheit) when input is RankineDouble castInput => RankineConverter.RankineToFahrenheit(castInput.Temperature),
         nameof(Kelvin) when input is CelsiusDouble castInput => CelsiusConverter.CelsiusToKelvin(castInput.Temperature),
         nameof(Kelvin) when input is FahrenheitDouble castInput => FahrenheitConverter.FahrenheitToKelvin(castInput.Temperature),
         nameof(Kelvin) when input is KelvinDouble castInput => KelvinConverter.KelvinToKelvin(castInput.Temperature),
         nameof(Kelvin) when input is GasDouble castInput => GasConverter.GasToKelvin(castInput.Temperature),
         nameof(Kelvin) when input is RankineDouble castInput => RankineConverter.RankineToKelvin(castInput.Temperature),
         nameof(Gas) when input is CelsiusDouble castInput => CelsiusConverter.CelsiusToGas(castInput.Temperature),
         nameof(Gas) when input is FahrenheitDouble castInput => FahrenheitConverter.FahrenheitToGas(castInput.Temperature),
         nameof(Gas) when input is KelvinDouble castInput => KelvinConverter.KelvinToGas(castInput.Temperature),
         nameof(Gas) when input is GasDouble castInput => GasConverter.GasToGas(castInput.Temperature),
         nameof(Gas) when input is RankineDouble castInput => RankineConverter.RankineToGas(castInput.Temperature),
         nameof(Rankine) when input is CelsiusDouble castInput => CelsiusConverter.CelsiusToRankine(castInput.Temperature),
         nameof(Rankine) when input is FahrenheitDouble castInput => FahrenheitConverter.FahrenheitToRankine(castInput.Temperature),
         nameof(Rankine) when input is KelvinDouble castInput => KelvinConverter.KelvinToRankine(castInput.Temperature),
         nameof(Rankine) when input is GasDouble castInput => GasConverter.GasToRankine(castInput.Temperature),
         nameof(Rankine) when input is RankineDouble castInput => RankineConverter.RankineToRankine(castInput.Temperature),
         _ => throw new ArgumentException($"Invalid type: {typeof(TInput).Name}")
     });
        public void Test_to_rankine_generic_from_rankine_returns_same_value()
        {
            // Arrange.
            var input = new RankineDouble(851.67);

            // Act.
            var result = input.To <Rankine>();

            // Assert.
            result.Should().Be(input.Temperature);
        }
        public void Test_to_kelvin_generic_from_rankine_returns_correct_value()
        {
            // Arrange.
            const double expected = 473.1499999999999d;
            var          input    = new RankineDouble(851.67);

            // Act.
            var result = input.To <Kelvin>();

            // Assert.
            result.Should().Be(expected);
        }
        public void Test_to_gas_generic_from_rankine_returns_correct_value()
        {
            // Arrange.
            const double expected = 3d;
            var          input    = new RankineDouble(806.67);

            // Act.
            var result = input.To <Gas>();

            // Assert.
            result.Should().Be(expected);
        }
        public void Test_to_fahrenheit_generic_from_rankine_returns_correct_value()
        {
            // Arrange.
            const double expected = 33.800999999999991d;
            var          input    = new RankineDouble(493.471d);

            // Act.
            var result = input.To <Fahrenheit>();

            // Assert.
            result.Should().Be(expected);
        }
        public void Test_to_celsius_generic_from_rankine_returns_correct_value()
        {
            // Arrange.
            const double expected = 1.0000000000000062d;
            var          input    = new RankineDouble(493.47d);

            // Act.
            var result = input.To <Celsius>();

            // Assert.
            result.Should().Be(expected);
        }
 /// <summary>
 /// Converts the RankineConverter <paramref name="input"/> to Celsius
 /// </summary>
 /// <param name="input"> The value to be converted. </param>
 /// <returns>
 /// The Celsius <see langword="double"/> result.
 /// </returns>
 public static double ToCelsius(this RankineDouble input)
 {
     return(RankineConverter.RankineToCelsius(input.Temperature));
 }
 /// <summary>
 /// Converts the RankineConverter <paramref name="input"/> to KelvinConverter
 /// </summary>
 /// <param name="input"> The value to be converted. </param>
 /// <exception cref="T:System.ArgumentOutOfRangeException">If calculated value is beyond the limits of the type.</exception>
 /// <returns>
 /// The KelvinConverter <see langword="double"/> result.
 /// </returns>
 public static double ToKelvin(this RankineDouble input)
 {
     return(RankineConverter.RankineToKelvin(input.Temperature));
 }
 /// <summary>
 /// Converts the RankineConverter <paramref name="input"/> to FahrenheitConverter
 /// </summary>
 /// <param name="input"> The value to be converted. </param>
 /// <exception cref="T:System.ArgumentOutOfRangeException">If calculated value is beyond the limits of the type.</exception>
 /// <returns>
 /// The FahrenheitConverter <see langword="double"/> result.
 /// </returns>
 public static double ToFahrenheit(this RankineDouble input)
 {
     return(RankineConverter.RankineToFahrenheit(input.Temperature));
 }