Ejemplo n.º 1
0
        public void Fahrenheit_To_Kelvin()
        {
            double toConvert      = 79.25;
            double convertedValue = TemperatureHelper.FahrenheitToKelvin(toConvert);

            Assert.Equal(299.4, convertedValue);
        }
Ejemplo n.º 2
0
        public double ConvertTemperature(TemperatureUom targetUom)
        {
            double result = 0;

            switch (TemperatureUom)
            {
            case TemperatureUom.Kelvin:
                if (targetUom == TemperatureUom.Celsius)
                {
                    result = TemperatureHelper.KelvinToCelsius(Temperature);
                }
                else if (targetUom == TemperatureUom.Fahrenheit)
                {
                    result = TemperatureHelper.KelvinToFahrenheit(Temperature);
                }
                else
                {
                    result = Temperature;
                }
                break;

            case TemperatureUom.Fahrenheit:
                if (targetUom == TemperatureUom.Celsius)
                {
                    result = TemperatureHelper.FahrenheitToCelsius(Temperature);
                }
                else if (targetUom == TemperatureUom.Kelvin)
                {
                    result = TemperatureHelper.FahrenheitToKelvin(Temperature);
                }
                else
                {
                    result = Temperature;
                }
                break;

            case TemperatureUom.Celsius:
                if (targetUom == TemperatureUom.Kelvin)
                {
                    result = TemperatureHelper.CelsiusToKelvin(Temperature);
                }
                else if (targetUom == TemperatureUom.Fahrenheit)
                {
                    result = TemperatureHelper.CelsiusToFahrenheit(Temperature);
                }
                else
                {
                    result = Temperature;
                }
                break;
            }

            Temperature    = result;
            TemperatureUom = targetUom;

            return(result);
        }
Ejemplo n.º 3
0
        public void Fahrenheit_To_Kelvin_Correct()
        {
            // Arrange
            double fahrenheit = 100;

            // Act
            double result        = TemperatureHelper.FahrenheitToKelvin(fahrenheit);
            double resultRounded = TemperatureHelper.FahrenheitToKelvin(fahrenheit, 0);

            // Assert
            Assert.Equal(310.78, result);
            Assert.Equal(311, resultRounded);
        }