Пример #1
0
        public void TransferAmountBetweenUsers()
        {
            var context = serviceProvider.GetRequiredService <DataContext>();

            var controller = new BankAccountsController(context);

            context.BankAccount.Add(bankAccount1);
            context.BankAccount.Add(bankAccount2);
            context.SaveChanges();

            double initialBalanceBankAccount1 = bankAccount1.Balance;
            double initialBalanceBankAccount2 = bankAccount2.Balance;

            string amount = "10";

            List <string> transferData = new List <string> {
                "10", bankAccount1.UserId.ToString(), bankAccount2.UserId.ToString()
            };

            var transferResult = controller.TransferBetweenUsers(transferData);

            Assert.Equal(initialBalanceBankAccount1 - Single.Parse(amount), bankAccount1.Balance - Single.Parse(amount));
            Assert.Equal(initialBalanceBankAccount2 + Single.Parse(amount), bankAccount2.Balance + Single.Parse(amount));
        }