Beispiel #1
0
        public void Can_be_compared()
        {
            var dkk1 = new Money(13, "DKK");
            var dkk2 = new Money(13, Currency.DKK);

            Assert.IsTrue(dkk1 == dkk2);
        }
 public void Money_instance_not_null()
 {
     var m = new Money("GBP", 1m);
     Assert.False(m == null);
     Assert.False(null == m);
     Assert.True(null != m);
     Assert.True(m != null);
 }
 public void Money_has_value_based_equality()
 {
     var m1 = new Money("GBP", 12.34m);
     var m2 = new Money("GBP", 12.34m);
     Assert.False(object.ReferenceEquals(m1, m2));
     Assert.True(m1.Equals(m2));
     Assert.True(m1.GetHashCode() == m2.GetHashCode());
 }
        public void Money_supports_native_subtraction_syntax()
        {
            var m = new Money(50);
            var m2 = new Money(49);

            var combined = m - m2;

            Assert.AreEqual(new Money(1), combined);
        }
        public void Money_supports_native_addition_syntax()
        {
            var m = new Money(200);
            var m2 = new Money(300);

            var combined = m + m2;

            Assert.AreEqual(new Money(500), combined);
        }
Beispiel #6
0
 public void Can_be_created_from_iso_code()
 {
     var eur = new Money(13, "EUR");
     Assert.IsInstanceOf<Money>(eur);
 }
Beispiel #7
0
 public void Can_be_created()
 {
     var sek = new Money(4711, Currency.SEK);
     Assert.AreEqual(4711, sek.Amount);
     Assert.AreEqual("SEK", sek.Currency.IsoCode);
 }
 public void Money_has_inequality_operator()
 {
     var m1 = new Money("GBP", 12.34m);
     var m2 = new Money("USD", 12.34m);
     Assert.True(m1 != m2);
 }
 public void Create_money_value_object_assigns_properties()
 {
     var m = new Money("GBP", 12.34m);
     Assert.Equal(12.34m, m.Amount);
     Assert.Equal("GBP", m.Currency);
 }