public void Test()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.That(converter.ToDecimal("2.721,55")).IsEqualTo(2721.55M);

            Check.That(converter.ToDecimal("2.721,55")).IsEqualTo(2721.55M);
        }
Exemplo n.º 2
0
 public static decimal GetAmount(this Myorder order, BankSyncConverter converter)
 {
     if (order.payment.amount?.amount != null)
     {
         return(converter.ToDecimal(order.payment.amount.amount));
     }
     else
     {
         return(converter.ToDecimal(order.totalCost.amount));
     }
 }
        public void Ambiguous_ShouldThrow()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.ThatCode(() => converter.ToDecimal("1.000,055,99"))
            .Throws <FormatException>();
            Check.ThatCode(() => converter.ToDecimal("1,000,055,99"))
            .Throws <FormatException>();

            Check.ThatCode(() => converter.ToDecimal("1.00.99"))
            .Throws <FormatException>();
        }
        public void BigNumbers()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.That(converter.ToDecimal("1,055.99")).IsEqualTo(1055.99M);

            Check.That(converter.ToDecimal("1.055,99")).IsEqualTo(1055.99M);

            Check.That(converter.ToDecimal("-1,000,055.99")).IsEqualTo(-1000055.99M);

            Check.That(converter.ToDecimal("1.000.055,99")).IsEqualTo(1000055.99M);
        }
        private decimal GetAmount(XElement operation)
        {
            XElement element = operation.Element("amount");

            if (element != null)
            {
                return(converter.ToDecimal(element.Value));
            }
            return(0);
        }
        public void Spaces()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.That(converter.ToDecimal("1 055,99")).IsEqualTo(1055.99M);
        }
        public void Commas()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.That(converter.ToDecimal("-55,99")).IsEqualTo(-55.99M);
        }
        public void Dots()
        {
            BankSyncConverter converter = new BankSyncConverter();

            Check.That(converter.ToDecimal("55.90")).IsEqualTo(55.9M);
        }