package ru.batov.procollection.testtask.bank;

import org.junit.Before;
import org.junit.Test;

import java.util.GregorianCalendar;
import java.util.List;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

/**
 * Created by Batov Nikolay on 22.04.2017.
 * Project name: junior
 */
public class MaxUserInDayTest {

    /**
     * Field initialize class for test.
     */
    private MaxUserInDay maxUserInDay = new MaxUserInDay();

    /**
     * Field initialize list for test.
     */
    private List<User> list;

    /**
     * Method add user for test before.
     */
    @Before
    public void initialize() {
        maxUserInDay.userAdd(new User("Tod", new GregorianCalendar(2017, 4, 1, 10, 0).getTime(), new GregorianCalendar(2017, 4, 1, 12, 30).getTime()));
        maxUserInDay.userAdd(new User("Lora", new GregorianCalendar(2017, 4, 1, 11, 30).getTime(), new GregorianCalendar(2017, 4, 1, 12, 20).getTime()));
        maxUserInDay.userAdd(new User("Frank", new GregorianCalendar(2017, 4, 1, 12, 00).getTime(), new GregorianCalendar(2017, 4, 1, 13, 0).getTime()));
        maxUserInDay.userAdd(new User("Max", new GregorianCalendar(2017, 4, 1, 12, 40).getTime(), new GregorianCalendar(2017, 4, 1, 14, 0).getTime()));
        list = maxUserInDay.getList();
    }

    /**
     * Test max user of the day.
     */
    @Test
    public void whenNeedGetMaxUserIsDayThenGet() {
        maxUserInDay.maxOfDay();
        assertThat(maxUserInDay.getMaxUserOfDay(), is(3));
    }

    /**
     * Test start time user of the day.
     */
    @Test
    public void whenNeedGetMaxStartTimeThenGet() {
        maxUserInDay.maxOfDay();
        assertThat(maxUserInDay.getStartTimeMaxUser(), is(new GregorianCalendar(2017, 4, 1, 12, 00).getTime()));
    }

    /**
     * Test finish time user of the day.
     */
    @Test
    public void whenNeedGetMaxFinishTimeThenGet() {
        maxUserInDay.maxOfDay();
        assertThat(maxUserInDay.getFinishTimeMaxUser(), is(new GregorianCalendar(2017, 4, 1, 12, 30).getTime()));
    }
}