示例#1
0
        public void ItShouldReturnItselfForKelvin()
        {
            var kelvin = new KelvinTemperature(0);
            var newKelvin = kelvin.Kelvin;

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

            Assert.That(actual, Is.EqualTo(expected));
        }
示例#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));
        }
示例#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));
        }
示例#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;
        }
示例#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);
        }
示例#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));
        }