/// <summary> /// Returns the real price value. /// </summary> /// <typeparam name="T">The concrete type of the price.</typeparam> /// <param name="price">The source price.</param> /// <returns>The real price value.</returns> public static decimal ValueToDecimal <T>(this T price) where T : IPriceWithCurrency { return(price?.Value == null ? 0M : MoneyHelper.ConvertFromIntRepresentationToDecimal(price.Value.Value, price.DecimalPlaces)); }
public void ConvertFromIntRepresentationToDecimal_ReturnsCorrectly(int sourceAmount, int?decimalPlaces, decimal expected) { var actual = MoneyHelper.ConvertFromIntRepresentationToDecimal(sourceAmount, decimalPlaces); Assert.AreEqual(expected, actual); }