package ru.matevosyan;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

/**
 * Created BankTest to test Bank class.
 * Created on 28.04.2017.
 * @author Matevosyan Vardan
 * @version 1.0
 */

public class BankTest {

    /**
     * Created whenTransferAmountFromFirstUserAccountToSecondUserAccountThanCheckThisAmount, to test transfer skills.
     * Testing when one user transfer amount from his first account to another one, who takes amount to his account.
     */

    @Test
    public void whenTransferAmountFromFirstUserAccountToSecondUserAccountThanCheckThisAmount() {

        //assign
        Bank bank = new Bank();

        User firstUser = new User("Tom", "KO23423F");
        Account firstUserAccount = new Account(50.50, "G45FD45-567");

        User secondUser = new User("Luis", "KG56423F");
        Account secondUserAccount = new Account(0.0, "G4H8F45-997");

        double amountToTransfer = 10.0;
        double expectedLastAmount = firstUserAccount.getValue() - amountToTransfer;

        //act
        bank.addUser(firstUser);
        bank.addAccountToUser(firstUser, firstUserAccount);

        bank.addUser(secondUser);
        bank.addAccountToUser(secondUser, secondUserAccount);

        bank.transferMoney(firstUser, firstUserAccount, secondUser, secondUserAccount, amountToTransfer);

        //assert
        assertThat(secondUserAccount.getValue(),is(amountToTransfer));
        assertThat(firstUserAccount.getValue(),is(expectedLastAmount));
    }

    /**
     * Created whenTransferAmountFromFirstUserAccountToSecondUserAccountThanCheckThisAmount, to test transfer skills.
     * Testing when one user transfer amount from his first account to his own account.
     */

    @Test
    public void whenTransferAmountFromFirstUserAccountToFirstUserSecondAccountThanCheckThisAmount() {

        //assign
        Bank bank = new Bank();

        User firstUser = new User("Tom", "KO23423F");
        Account firstUserAccount = new Account(50.50, "G45FD45-567");
        Account firstUserSecondAccount = new Account(0.0, "G4H8F45-997");
        double amountToTransfer = 35.5;
        double expectedLastAmount = firstUserAccount.getValue() - amountToTransfer;

        //act
        bank.addUser(firstUser);
        bank.addAccountToUser(firstUser, firstUserAccount);
        bank.addAccountToUser(firstUser, firstUserSecondAccount);

        bank.transferMoney(firstUser, firstUserAccount, firstUser, firstUserSecondAccount, amountToTransfer);

        //assert
        assertThat(firstUserSecondAccount.getValue(),is(amountToTransfer));
        assertThat(firstUserAccount.getValue(),is(expectedLastAmount));
    }

}
@@ -1435,32 +1435,33 @@
 ount.getValue(),
+ 
 is(amountToTrans
@@ -1506,32 +1506,33 @@
 ount.getValue(),
+ 
 is(expectedLastA
@@ -2611,16 +2611,17 @@
 Value(),
+ 
 is(amoun
@@ -2682,16 +2682,17 @@
 Value(),
+ 
 is(expec
@@ -2715,9 +2715,1284 @@
 %0A    %7D%0A%0A
+    /**%0A     * Created whenDeleteTheUserThanCheckIfIsExist to test, opportunity to delete user from base.%0A     */%0A%0A    @Test%0A    public void whenDeleteTheUserThanCheckIfIsExist() %7B%0A%0A        //assign%0A        Bank bank = new Bank();%0A        User firstUser = new User(%22Tom%22, %22KO23423F%22);%0A        Account firstUserAccount = new Account(50.50, %22G45FD45-567%22);%0A%0A        //act%0A        bank.addUser(firstUser);%0A        bank.addAccountToUser(firstUser, firstUserAccount);%0A        bank.deleteAccountFromUser(firstUser, firstUserAccount);%0A%0A        //assert%0A        assertThat(bank.getAccountHolder().get(firstUser).contains(firstUserAccount), is(false));%0A    %7D%0A%0A    /**%0A     * Created whenDeleteTheUserAccountThanCheckIfIsExist to test, opportunity to delete user account from user.%0A     */%0A%0A    @Test%0A    public void whenDeleteTheUserAccountThanCheckIfIsExist() %7B%0A%0A        //assign%0A        Bank bank = new Bank();%0A        User firstUser = new User(%22Tom%22, %22KO23423F%22);%0A        Account firstUserAccount = new Account(50.50, %22G45FD45-567%22);%0A        //act%0A        bank.addUser(firstUser);%0A        bank.addAccountToUser(firstUser, firstUserAccount);%0A        bank.deleteUser(firstUser);%0A%0A        //assert%0A        assertThat(bank.getAccountHolder().containsKey(firstUser), is(false));%0A    %7D%0A%0A
 %7D

add two test method and all is passed