Exemplo n.º 1
0
        public void When_AddMoney_Then_ShouldReturn_ExpectedValue(decimal input1, decimal input2, decimal expected)
        {
            var currency = new Currency()
            {
                Name = "USD"
            };

            var user = new MoneyExchange.User.Domain.Models.User()
            {
                Balances = new List <Balance>()
                {
                    new Balance()
                    {
                        Id       = 1,
                        Currency = currency,
                        Amount   = 0
                    }
                }
            };

            user.AddMoney(new Money(input1, currency));
            user.AddMoney(new Money(input2, currency));

            user.GetBalance()[currency.Name].ShouldBe(expected);
        }
Exemplo n.º 2
0
        public void When_ExchangeMoney_Then_ShouldReturn_ExpectedValue(decimal balance, decimal amount, decimal expected)
        {
            var currencyFrom = new Currency()
            {
                Name = "USD"
            };
            var currencyTo = new Currency()
            {
                Name = "PHP"
            };

            var user = new MoneyExchange.User.Domain.Models.User()
            {
                Balances = new List <Balance>()
                {
                    new Balance()
                    {
                        Id       = 1,
                        Currency = currencyFrom,
                        Amount   = balance
                    }
                }
            };

            user.ExchangeMoney(new Money(amount, currencyFrom), currencyTo);

            user.GetBalance()[currencyFrom.Name].ShouldBe(expected);
        }
Exemplo n.º 3
0
        public void When_GetBalance_And_NoCurrencyFound_Then_ShouldReturn_Null()
        {
            var user = new MoneyExchange.User.Domain.Models.User()
            {
                Balances = new List <Balance>()
            };

            var result = user.GetBalance("");

            result.ShouldBeNull();
        }