public void ToStringShouldWork(double value, string expected) { var original = new JoulesEnergy(value); var actual = original.ToString(); Assert.That(actual, Is.EqualTo(expected)); }
public void ItShouldReturnItselfForJoules() { var original = new JoulesEnergy(0); var conversion = original.Joules; Assert.That(original, Is.SameAs(conversion)); }
public void ItShouldConvertToKilowattHoursProperly(double before, double after) { var original = new JoulesEnergy(before); var conversion = original.KilowattHours; Assert.That(conversion.Value, Is.EqualTo(after).Within(0.001)); }
public static IEnergy Parse(double value, string type) { IEnergy result; switch (type.ToLower()) { case "j": case "joule": case "joules": result = new JoulesEnergy(value); break; case "kwh": case "kilowatt hour": case "kilowatt hours": result = new KilowattHoursEnergy(value); break; default: throw new Exception("Could not determine type " + type); } return(result); }
public static IEnergy Parse(double value, string type) { IEnergy result; switch (type.ToLower()) { case "j": case "joule": case "joules": result = new JoulesEnergy(value); break; case "kwh": case "kilowatt hour": case "kilowatt hours": result = new KilowattHoursEnergy(value); break; default: throw new Exception("Could not determine type " + type); } return result; }