public void InvalidArithmetic() { Assert.That(delegate { return(Foot.S(3) - Ounce.S(4)); }, Throws.ArgumentException); // The following should not compile: //var total = Celsius.S(10) + Fahrenheit.S(50); //var total = Inch.Es(10) + Fahrenheit.S(50); }
public void Arithmetic() { Assert.AreEqual(-Ounce.S(4), -(Pint.S(0.25))); Assert.AreEqual(Cup.S(1), Ounce.S(4) + Pint.S(0.25)); Assert.AreEqual(Pint.S(-0.25), Quart.S(0.25) - Ounce.S(12)); Assert.AreEqual(-Foot.S(3), Inch.Es(36) - Yard.S(2)); }
public void Arithmetic() { Assert.AreEqual(Tablespoon.S(-3), -Tablespoon.S(3)); Assert.AreEqual(-Cup.S(1.5), Cup.S(6.5) - Cup.S(8)); Assert.AreEqual(-Tablespoon.S(24), Cup.S(6.5) - Gallon.S(0.5)); Assert.AreEqual(-24.Tablespoons(), 6.5.Cups() - 0.5.Gallons()); Assert.AreEqual(-Foot.S(6), Inch.Es(18) - Yard.S(2.5)); }
public void EqualityOfDifferentUnit() { Assert.AreNotEqual(Cup.S(4), Gallon.S(4)); Assert.AreEqual(Teaspoon.S(3), Tablespoon.S(1)); Assert.AreEqual(Ounce.S(16), Quart.S(0.5)); Assert.AreEqual(Gallon.S(3), Teaspoon.S(2304)); Assert.AreEqual(Foot.S(4.5), Yard.S(1.5)); Assert.AreEqual(Mile.S(2), Inch.Es(126720)); Assert.AreNotEqual(Inch.Es(1), Teaspoon.S(1)); Assert.AreNotEqual(Inch.Es(1), Celsius.S(1)); }
public void EqualityOfUnlikeUnits() { Assert.AreEqual(Tablespoon.S(6), Ounce.S(3)); Assert.AreEqual(Tablespoon.S(8), Cup.S(0.5)); Assert.AreEqual(Cup.S(0.5), Tablespoon.S(8)); Assert.AreEqual(Gallon.S(2), Teaspoon.S(1536)); Assert.AreNotEqual(Cup.S(6), Tablespoon.S(6)); Assert.AreEqual(Inch.S(126720), Mile.S(2)); Assert.AreNotEqual(Inch.Es(1), Teaspoon.S(1)); Assert.AreNotEqual(Foot.S(2), Cup.S(0.5)); Assert.AreEqual(6.Tablespoons(), 3.Ounces()); Assert.AreEqual(8.Tablespoons(), 0.5.Cups()); Assert.AreEqual(0.5.Cups(), 8.Tablespoons()); Assert.AreEqual(2.Gallons(), 1536.Teaspoons()); Assert.AreNotEqual(6.Cups(), 6.Tablespoons()); Assert.AreNotEqual(1.Inches(), 1.Teaspoons()); Assert.AreNotEqual(2.Feet(), 0.5.Cups()); }
public static RatioQuantity Feet(this int amount) => Foot.S(amount);