/// <summary> /// Sets the value represented as decimal to price. /// </summary> /// <typeparam name="T">The concrete type of the price.</typeparam> /// <param name="price">The target price.</param> /// <param name="sourceValue">Real price value.</param> /// <returns>Price value as int.</returns> public static int SetDecimalValue <T>(this T price, decimal sourceValue) where T : IPriceWithCurrency { var value = MoneyHelper.ConvertFromDecimalRepresentationToInt(sourceValue, price.DecimalPlaces); price.Value = value; return(value); }
public void ConvertFromDecimalRepresentationToInt_ReturnsCorrectly(decimal sourceAmount, int?decimalPlaces, int expected) { var actual = MoneyHelper.ConvertFromDecimalRepresentationToInt(sourceAmount, decimalPlaces); Assert.AreEqual(expected, actual); }