//public static implicit operator Money(decimal value) //{ // return new Money(value); //} //public static implicit operator Money(double value) //{ // return (decimal)value; //} /// <summary> /// Currency is compatible if the same or either money object has zero value. /// </summary> private static bool AreCompatibleCurrencies(Money m, Money m2) { return IsZero(m.Value) || IsZero(m2.Value) || m.CurrencyCode.Equals(m2.CurrencyCode); }
public bool Equals(Money other) { return _value == other._value && string.Equals(_currencyCode, other._currencyCode); }
public void CannotAddDifferentCurrenciesTest() { var money = new Money(1.11m, "PLN") + new Money(2.22m, "EUR"); }
public void MultiplyTest() { Money result = new Money(1.11).MultiplyBy(5.0); result.ShouldEqual(new Money(5.55)); }
public void AddTest() { Money result = new Money(1.11) + new Money(2.22); result.ShouldEqual(new Money(3.33)); }