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 Direction GetDirection(float horizontal, float vertical) { if (Mathf.Sqrt(horizontal * horizontal + vertical * vertical) < Deadzone) { return(Direction.Neutral); } float absX = Mathf.Abs(horizontal); float absY = Mathf.Abs(vertical); Quart quart = (absY < absX * HorizontalRatio) ? Quart.Horizontal : (absY < absX * VerticalRatio) ? Quart.Diagonal : Quart.Vertical; if (quart == Quart.Horizontal) { return(horizontal > 0 ? Direction.Right : Direction.Left); } if (quart == Quart.Vertical) { return(vertical > 0 ? Direction.Up : Direction.Down); } if (vertical > 0) { return(horizontal > 0 ? Direction.UpRight : Direction.UpLeft); } else { return(horizontal > 0 ? Direction.DownRight : Direction.DownLeft); } }
public void Quantity() { RatioQuantity[] quantities = { Teaspoon.S(10), Quart.S(1), Tablespoon.S(6), Ounce.S(13) }; Assert.AreEqual(Pint.S(2), Sequence.Max(quantities)); }
public void Quantity() { var quantities = new List <IntervalQuantity> { Teaspoon.S(10), Quart.S(1), Tablespoon.S(6), Ounce.S(13) }; Assert.AreEqual(Pint.S(2), Sequence.Best(quantities)); }
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 static RatioQuantity Quarts(this int amount) => Quart.S(amount);
public static RatioQuantity Quarts(this double amount) => Quart.S(amount);
public void Hash() { Assert.AreEqual(Tablespoon.S(2).GetHashCode(), Tablespoon.S(2).GetHashCode()); Assert.AreEqual(Ounce.S(16).GetHashCode(), Quart.S(0.5).GetHashCode()); }