Esempio n. 1
0
        public void CelsiusToFahrenheit()
        {
            // Arrange
            var expected = 57.2;

            // Act
            var actual = _sut.Convert("14,0c");

            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void ConvertTemperature(double temperature, TemperatureScale scaleFrom, TemperatureScale scaleTo)
        {
            double result = temperatureConverter.Convert(temperature, scaleFrom, scaleTo);

            switch (scaleTo.Name)
            {
            case TemperatureConverter.KelvinScaleName:

                view.SetResultTemperature("в градусах Кельвина", result);
                break;

            case TemperatureConverter.FahrenheitScaleName:

                view.SetResultTemperature("в градусах Фаренгейта", result);
                break;

            case TemperatureConverter.CelsiusScaleName:

                view.SetResultTemperature("в градусах Цельсия", result);
                break;

            default:
                throw new ArgumentException(scaleTo.Name, "Указана некорретная температурная шкала.");
            }
        }
Esempio n. 3
0
        private static void Main(string[] args)
        {
            Console.WriteLine("For at afslutte, tast q og <Enter>");

            while (true)
            {
                var input = ParseInput();

                if (input.Equals("q"))
                {
                    Environment.Exit(0);
                }

                var temperature          = ParseTemperature(input);
                var temperatureType      = temperature.EndsWith('c') ? " grader Fahrenheit" : " grader Celsius";
                var temperatureConverted = TemperatureConverter.Convert(temperature);

                Console.WriteLine($"Omregnet temperatur er: {temperatureConverted}{temperatureType}");
                Console.WriteLine();
            }
        }
        public void ConvertKelvinToCelsiusRange_130_To_140_RoundedTo2DP([Range(130d, 140d, 1d)] double temperature,
                                                                        [Values(-143, -142, -141, -140, -139, -138, -137, -136, -135, -134, -133)] double expected)
        {
            double actual = _sut.Convert(temperature, _kelvinToCelsius, RoundBy);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void ConvertFahrenheitToKelvinRange_0_To_10_RoundedTo0DP([Range(0, 10, 1)] double temperature,
                                                                        [Values(255, 256, 256, 257, 258, 258, 259, 259, 260, 260, 261)] double expected)
        {
            double actual = _sut.Convert(temperature, _fahrenheitToKelvin, RoundBy);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void ConvertCelsiusToFahrenheitRange_0_To_10_RoundedTo2DP([Range(0d, 10d, 1d)] double temperature,
                                                                         [Values(32.00, 33.80, 35.60, 37.40, 39.20, 41.00, 42.80, 44.60, 46.40, 48.20, 50.00)] double expected)
        {
            double actual = _sut.Convert(temperature, _celsiusToFahrenheit, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
Esempio n. 7
0
 public PlaceAndTemperature Convert(ITemperatureConverter converter)
 {
     return(new PlaceAndTemperature(Name, converter.Convert(Temperature), converter.TargetUnit));
 }
Esempio n. 8
0
        public void ConvertKelvinToFahrenheitRange_130_To_140_RoundedTo2DP([Range(130d, 140d, 1d)] double temperature,
                                                                           [Values(-225.67, -223.87, -222.07, -220.27, -218.47, -216.67, -214.87, -213.07, -211.27, -209.47, -207.67)] double expected)
        {
            double actual = _sut.Convert(temperature, _kelvinToFahrenheit, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
        public void ConvertCelsiusToKelvinRange_0_To_10_RoundedTo2DP([Range(0d, 10d, 1d)] double temperature,
                                                                     [Values(273.15, 274.15, 275.15, 276.15, 277.15, 278.15, 279.15, 280.15, 281.15, 282.15, 283.15)] double expected)
        {
            double actual = _sut.Convert(temperature, _celsiusToKelvin, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
Esempio n. 10
0
        public void ConvertFahrenheitToCelsiusRange_0_To_10_RoundedTo0DP([Range(0d, 10d, 1d)] double temperature,
                                                                         [Values(-18, -17, -17, -16, -16, -15, -14, -14, -13, -13, -12)] double expected)
        {
            double actual = _sut.Convert(temperature, _fahrenheitToCelsius, RoundBy);

            Assert.AreEqual(expected, actual);
        }
        public void ConvertKelvinToCelsiusRange_130_To_140_RoundedTo2DP([Range(130d, 140d, 1d)] double temperature,
                                                                        [Values(-143.15, -142.15, -141.15, -140.15, -139.15, -138.15, -137.15, -136.15, -135.15, -134.15, -133.15)] double expected)
        {
            double actual = _sut.Convert(temperature, _kelvinToCelsius, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
        public void ConvertCelsiusToFahrenheitRange_0_To_10_RoundedTo0DP([Range(0d, 10d, 1d)] double temperature,
                                                                         [Values(32, 34, 36, 37, 39, 41, 43, 45, 46, 48, 50)] double expected)
        {
            double actual = _sut.Convert(temperature, _celsiusToFahrenheit, RoundBy);

            Assert.AreEqual(expected, actual);
        }
        public void ConvertFahrenheitToKelvinRange_0_To_10_RoundedTo2DP([Range(0, 10, 1)] double temperature,
                                                                        [Values(255.37, 255.92, 256.48, 257.03, 257.59, 258.15, 258.706, 259.261, 259.817, 260.372, 260.928)] double expected)
        {
            double actual = _sut.Convert(temperature, _fahrenheitToKelvin, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
Esempio n. 14
0
        public void ConvertKelvinToFahrenheitRange_130_To_140_RoundedTo2DP([Range(130d, 140d, 1d)] double temperature,
                                                                           [Values(-226, -224, -222, -220, -218, -217, -215, -213, -211, -209, -208)] double expected)
        {
            double actual = _sut.Convert(temperature, _kelvinToFahrenheit, RoundBy);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 15
0
        public void ConvertFahrenheitToCelsiusRange_0_To_10_RoundedTo2DP([Range(0d, 10d, 1d)] double temperature,
                                                                         [Values(-17.78, -17.22, -16.67, -16.11, -15.56, -15, -14.44, -13.89, -13.33, -12.78, -12.22)] double expected)
        {
            double actual = _sut.Convert(temperature, _fahrenheitToCelsius, RoundBy);

            Assert.AreEqual(expected, actual, _toleranceLevel);
        }
Esempio n. 16
0
        public void ConvertCelsiusToKelvinRange_0_To_10_RoundedTo0DP([Range(0d, 10d, 1d)] double temperature,
                                                                     [Values(273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283)] double expected)
        {
            double actual = _sut.Convert(temperature, _celsiusToKelvin, RoundBy);

            Assert.AreEqual(expected, actual);
        }