public void AreUnitsEqual_When_UnitsArePrefixedBaseUnitAndPrefixedUnitOfKg_Then_ResultShouldBeTrue()
        {
            var prefixedBaseUnitKg = UnitDefinitions.KiloGram;
            var prefixedUnitKg     = UnitDefinitions.Gram.GetPrefixedUnit(Prefixes.Kilo);

            var result = UnitEqualityHelper.AreUnitsEqual(prefixedBaseUnitKg, prefixedUnitKg);

            result.Should().BeTrue();
        }
        /// <summary>
        /// Executes the operation.
        /// </summary>
        /// <param name="lhs">The LHS quantity.</param>
        /// <param name="rhs">The RHS quantity.</param>
        /// <returns>
        /// The resulting value.
        /// </returns>
        public double Execute(IQuantity lhs, IUnit rhs)
        {
            var valueUnit = lhs.Unit;
            var value     = lhs.Value;

            if (!UnitEqualityHelper.AreUnitsEqual(valueUnit, rhs))
            {
                value = rhs.FromBase(valueUnit.ToBase(value));
            }

            return(value);
        }
        /// <summary>
        /// Compares the lhs to the rhs.
        /// </summary>
        /// <param name="lhs">The LHS quantity.</param>
        /// <param name="rhs">The RHS quantity.</param>
        /// <returns>The result of <see cref="int"/> Compare based the rhs converted to the same unit as lhs.</returns>
        public static int CompareTo(IQuantity lhs, IQuantity rhs)
        {
            var lhsUnit = lhs.Unit;
            var rhsUnit = rhs.Unit;

            if (!UnitEqualityHelper.AreBaseUnitsEqual(lhsUnit, rhsUnit))
            {
                throw new UnitMismatchException(OperationType.Compare, lhsUnit, rhsUnit);
            }

            var rhsValue = QuantityOperations.ConvertToUnit(rhs, lhs.Unit);

            return(lhs.Value.CompareTo(rhsValue));
        }
        /// <summary>
        /// Checks if the lhs and the rhs are equal.
        /// </summary>
        /// <param name="lhs">The LHS quantity.</param>
        /// <param name="rhs">The RHS quantity.</param>
        /// <returns>
        /// A value indication whether the lhs and the rhs are equal.
        /// </returns>
        public static bool AreEqual(IQuantity lhs, IQuantity rhs)
        {
            if (lhs == null || rhs == null)
            {
                return(false);
            }

            var lhsUnit = lhs.Unit;
            var rhsUnit = rhs.Unit;

            if (!UnitEqualityHelper.AreBaseUnitsEqual(lhsUnit, rhsUnit))
            {
                return(false);
            }

            var rhsValue = QuantityOperations.ConvertToUnit(rhs, lhsUnit);

            return(lhs.Value.Equals(rhsValue));
        }
 /// <summary>
 /// Determines whether the specified <see cref="object"/>, is equal to this instance.
 /// </summary>
 /// <param name="other">
 /// The <see cref="object"/> to compare with this instance.
 /// </param>
 /// <returns>
 ///     <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public override bool Equals(object other)
 {
     return(UnitEqualityHelper.AreUnitsEqual(this, other));
 }
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return(UnitEqualityHelper.GetHashCode(this));
 }
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">
 /// An object to compare with this object.
 /// </param>
 /// <returns>
 ///     <c>true</c> if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
 /// </returns>
 public bool Equals(IUnit other)
 {
     return(UnitEqualityHelper.AreUnitsEqual(this, other));
 }