package ru.job4j.condition;

import org.junit.Test;

import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.assertThat;

/**
 * Test.
 *
 * @author Artem Khizhniakov (mailto:artem_khizhniakov@mail.ru).
 * @version $Id$.
 * @since 21.09.2017.
 */
public class TriangleTest {
    /**
     * Test area.
     */
    @Test
    public void whenAreaSetThreePointsThenTriangleArea() {
        // create three objects of class Point.
        Point a = new Point(0, 0);
        Point b = new Point(0, 2);
        Point c = new Point(2, 0);
        // Create a triangle object and pass point objects to it.
        Triangle triangle = new Triangle(a, b, c);
        // Calculate the area.
        double result = triangle.area();
        // Set the expected result.
        double expected = 2D;
        // Check the result and the expected value.
        assertThat(result, closeTo(expected, 0.1));
    }

}
