Esempio n. 1
0
        public void ItShouldReturnItselfForKelvin()
        {
            var kelvin = new KelvinTemperature(0);
            var newKelvin = kelvin.Kelvin;

            Assert.That(kelvin, Is.SameAs(newKelvin));
        }
Esempio n. 2
0
        public void ToStringShouldWork(double value, string expected)
        {
            var kelvin = new KelvinTemperature(value);
            var actual = kelvin.ToString();

            Assert.That(actual, Is.EqualTo(expected));
        }
Esempio n. 3
0
        public void ItShouldConvertToFarenheightProperly(double before, double after)
        {
            var celsius = new KelvinTemperature(before);
            var fahrenheit = celsius.Fahrenheit;

            Assert.That(fahrenheit.Value, Is.EqualTo(after).Within(0.001));
        }
Esempio n. 4
0
        public void ItShouldConvertToCelsiustProperly(double before, double after)
        {
            var kelvin = new KelvinTemperature(before);
            var celsius = kelvin.Celsius;

            Assert.That(celsius.Value, Is.EqualTo(after).Within(0.001));
        }
Esempio n. 5
0
        public static ITemperature Parse(double value, string type)
        {
            ITemperature result;

            switch (type.ToLower())
            {
                case "c":
                case "celsius":
                    result = new CelsiusTemperature(value);
                    break;

                case "f":
                case "fahrenheit":
                    result = new FahrenheitTemperature(value);
                    break;

                case "k":
                case "kelvin":
                    result = new KelvinTemperature(value);
                    break;

                default:
                    throw new Exception("Could not determine type " + type);
            }

            return result;
        }
Esempio n. 6
0
        public static ITemperature Parse(double value, string type)
        {
            ITemperature result;

            switch (type.ToLower())
            {
            case "c":
            case "celsius":
                result = new CelsiusTemperature(value);
                break;

            case "f":
            case "fahrenheit":
                result = new FahrenheitTemperature(value);
                break;

            case "k":
            case "kelvin":
                result = new KelvinTemperature(value);
                break;

            default:
                throw new Exception("Could not determine type " + type);
            }

            return(result);
        }
Esempio n. 7
0
        public void ItAddsCorrectly(double before, double amount, double after)
        {
            var initial = new KelvinTemperature(before);
            var result = initial.Add(amount);

            Assert.That(initial, Is.Not.SameAs(result));
            Assert.That(initial.Value, Is.EqualTo(before));
            Assert.That(result.Value, Is.EqualTo(after));
        }