Пример #1
0
 //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);
 }
Пример #2
0
 public bool Equals(Money other)
 {
     return _value == other._value && string.Equals(_currencyCode, other._currencyCode);
 }
Пример #3
0
 public void CannotAddDifferentCurrenciesTest()
 {
     var money = new Money(1.11m, "PLN") + new Money(2.22m, "EUR");
 }
Пример #4
0
 public void MultiplyTest()
 {
     Money result = new Money(1.11).MultiplyBy(5.0);
     result.ShouldEqual(new Money(5.55));
 }
Пример #5
0
 public void AddTest()
 {
     Money result = new Money(1.11) + new Money(2.22);
     result.ShouldEqual(new Money(3.33));
 }