public void ItShouldReturnItselfForKelvin() { var kelvin = new KelvinTemperature(0); var newKelvin = kelvin.Kelvin; Assert.That(kelvin, Is.SameAs(newKelvin)); }
public void ToStringShouldWork(double value, string expected) { var kelvin = new KelvinTemperature(value); var actual = kelvin.ToString(); Assert.That(actual, Is.EqualTo(expected)); }
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)); }
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)); }
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; }
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); }
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)); }