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);
        }
예제 #3
0
 /// <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));
 }
예제 #4
0
 /// <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));
 }