Exemplo n.º 1
0
        public void Deposit_WithValidAmount_UpdatesLastTransactionBalance()
        {
            //Arrange
            var user = new User
            {
                Username  = "******",
                FirstName = "Demo",
                LastName  = "User",
                Password  = "******"
            };

            new AuthService().Register(user);

            decimal depositAmount1 = 5;
            decimal depositAmount2 = 2;
            decimal expected       = depositAmount1 + depositAmount2;
            UserTransactionService transactionService = new UserTransactionService();

            //act
            transactionService.Deposit(user.Id, depositAmount1);
            transactionService.Deposit(user.Id, depositAmount2);

            //Assert
            var balance = transactionService.GetCurrentBalanceForUser(user.Id);

            Assert.AreEqual(expected, balance, "Wrong balance value");
        }
Exemplo n.º 2
0
        public override void Run(bool clearScreen = true)
        {
            if (clearScreen)
            {
                Console.Clear();
            }
            Console.WriteLine($"Deposit for {User.Username}\n");
            Console.Write("Enter amount to deposit: ");
            var amount = UserInputHelper.GetDecimal();

            Console.Write($"Depost {amount:C}. Are you sure? (y/n) : ");
            var confirm = Console.ReadLine();

            if (confirm == "y" || confirm == "Y")
            {
                var res = UserTransactionService.Deposit(User.Id, amount);
                if (res.Success)
                {
                    Console.WriteLine("Deposit Success!");
                }
                else
                {
                    Console.WriteLine($"Deposit Failed. {res.Errors}");
                }
            }
            else
            {
                Console.WriteLine("Deposit Cancelled!");
            }
            ShowDoneOptions();
        }
Exemplo n.º 3
0
        public void Deposit_WithValidAmount_AddedToTransactionList()
        {
            //Arrange
            var user = new User
            {
                Username  = "******",
                FirstName = "Demo",
                LastName  = "User",
                Password  = "******"
            };

            new AuthService().Register(user);
            UserTransactionService transactionService = new UserTransactionService();

            //act
            transactionService.Deposit(user.Id, 5);

            //Assert
            var allTransactions = transactionService.GetTransactionsForUser(user.Id);

            Assert.IsTrue(allTransactions.Count() > 0, "Wrong transaction list count");
        }
Exemplo n.º 4
0
        public void Transaction_LastTransactionNotNull()
        {
            //Arrange
            var user = new User
            {
                Username  = "******",
                FirstName = "Demo",
                LastName  = "User",
                Password  = "******"
            };

            new AuthService().Register(user);
            UserTransactionService transactionService = new UserTransactionService();

            //act
            transactionService.Deposit(user.Id, 5);

            //Assert
            var lastTransaction = transactionService.GetLastTransactionForUser(user.Id);

            Assert.IsNotNull(lastTransaction, "Wrong last transaction is null");
        }