Ejemplo n.º 1
0
        public void Money_Incremented_ShouldBeIncremented(decimal value, decimal increment, decimal expected)
        {
            var money = new Money(value);

            money += increment;
            Assert.Equal(expected, money.Value);
        }
Ejemplo n.º 2
0
        public void Money_ToString_StringMoney()
        {
            Assert.Equal("0.00", new Money(0M).ToString());
            Assert.Equal("0.00", new Money(0.0M).ToString());
            Assert.Equal("0.00", new Money(0.00M).ToString());
            Assert.Equal("0.01", new Money(0.01M).ToString());
            Assert.Equal("0.10", new Money(0.1M).ToString());
            Assert.Equal("0.10", new Money(0.10M).ToString());
            Assert.Equal("0.10", new Money(00.1M).ToString());
            Assert.Equal("1.00", new Money(1M).ToString());
            Assert.Equal("1.10", new Money(1.1M).ToString());
            Assert.Equal("1.01", new Money(1.01M).ToString());
            Assert.Equal("0.99", new Money(0.99M).ToString());
            Assert.Equal("1.00", new Money(1M).ToString());
            Assert.Equal("12.34", new Money(12.34M).ToString());

            Assert.Equal("0.00", new Money(0M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.00", new Money(0.0M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.00", new Money(0.00M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.01", new Money(0.01M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.10", new Money(0.1M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.10", new Money(0.10M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.10", new Money(00.1M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("1.00", new Money(1M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("1.10", new Money(1.1M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("1.01", new Money(1.01M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("0.99", new Money(0.99M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("1.00", new Money(1M).ToString(CultureInfo.InvariantCulture));
            Assert.Equal("12.34", new Money(12.34M).ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 3
0
        public void NewMoney_Value_ProperInstantiated()
        {
            var money1 = new Money(0);

            Assert.Equal(0, money1.Value);
            Assert.Equal(0, money1.IntegralPart);

            var money1_ = Money.NewMoney(0);

            Assert.Equal(0, money1_.Value);
            Assert.Equal(0, money1_.IntegralPart);

            var money2 = new Money(0m);

            Assert.Equal(0m, money2.Value);
            Assert.Equal(0m, money2.IntegralPart);

            var money2_ = Money.NewMoney(0m);

            Assert.Equal(0m, money2_.Value);
            Assert.Equal(0m, money2_.IntegralPart);

            var money3 = new Money(12.45m);

            Assert.Equal(12.45m, money3.Value);
            Assert.Equal(12m, money3.IntegralPart);

            var money3_ = Money.NewMoney(12.45m);

            Assert.Equal(12.45m, money3_.Value);
            Assert.Equal(12m, money3_.IntegralPart);

            var money4 = new Money(0.45m);

            Assert.Equal(0.45m, money4.Value);
            Assert.Equal(0m, money4.IntegralPart);

            var money4_ = Money.NewMoney(0.45m);

            Assert.Equal(0.45m, money4_.Value);
            Assert.Equal(0m, money4_.IntegralPart);
        }
Ejemplo n.º 4
0
        public void Decimal_CastToMoney_ShouldByCasted(decimal expected)
        {
            var actual = (Money)expected;

            Assert.Equal(expected, actual.Value);
        }
Ejemplo n.º 5
0
        public void Money_CastToDecimal_ShouldBeCasted(decimal expected)
        {
            var actual = (decimal) new Money(expected);

            Assert.Equal(expected, actual);
        }