package by.vorokhobko;

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

/**
 * CalculatorTest.
 *
 * Class CalculatorTest for testing class Calculator.
 * @author Evgeny Vorokhobko (vorokhobko2011@yandex.ru).
 * @since 13.11.2016.
 * @version 1.
 */

 public class CalculatorTest {
	 /**
	  * numberExeption.
	  */
	private final double numberExeption = 0.1;
	 /**
	  * @Test.
	  * Add test with positive numbers.
	  */
	public void testWhenPassArgToAddItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 2;
		final double second = 2;
		final double resultingNumber = 4;
		calc.add(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	  /**
	  * @Test.
	  * Add test with negative numbers.
	  */
	public void testWhenPassArgToAddItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = (-2);
		final double second = (-2);
		final double resultingNumber = (-4);
		calc.add(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	  /**
	  * @Test.
	  * Add test with second negative number and first positive number.
	  */
	public void testWhenPassArgToAddItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 4;
		final double second = (-2);
		final double resultingNumber = 2;
		calc.add(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	  * @Test.
	  * Take test with positive numbers.
	  */
	public void testWhenPassArgToTakeItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 4;
		final double second = 2;
		final double resultingNumber = 2;
		calc.take(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	  * @Test.
	  * Take test with negative numbers.
	  */
	public void testWhenPassArgToTakeItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = (-4);
		final double second = (-2);
		final double resultingNumber = (-2);
		calc.take(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	  /**
	  * @Test.
	  * Take test with second negative number and first positive number.
	  */
	public void testWhenPassArgToTakeItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 4;
		final double second = (-2);
		final double resultingNumber = 6;
		calc.take(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	/**
	 * @Test.
	 * Multiple test with positive numbers.
	 */
	public void testWhenPassArgToMultItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 3;
		final double second = 2;
		final double resultingNumber = 6;
		calc.mult(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	 * @Test.
	 * Multiple test with negative numbers.
	 */
	public void testWhenPassArgToMultItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = (-3);
		final double second = (-2);
		final double resultingNumber = 6;
		calc.mult(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	 * @Test.
	 * Multiple test with first positive number and second negative number.
	 */
	public void testWhenPassArgToMultItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 3;
		final double second = (-2);
		final double resultingNumber = (-6);
		calc.mult(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	/**
	 * @Test.
	 * Sharing test with positive numbers.
	 */
	public void testWhenPassArgToSharItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 10;
		final double second = 2;
		final double resultingNumber = 5;
		calc.shar(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	 * @Test.
	 * Sharing test with negative numbers.
	 */
	public void testWhenPassArgToSharItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = (-10);
		final double second = (-2);
		final double resultingNumber = 5;
		calc.shar(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
	 /**
	 * @Test.
	 * Sharing test with first positive number and second negative number.
	 */
	public void testWhenPassArgToSharItShouldReturn() {
		Calculator calc = new Calculator();
		final double first = 10;
		final double second = (-2);
		final double resultingNumber = (-5);
		calc.shar(first, second);
		double result = calc.getResult();
		assertThat(result, is(closeTo(resultingNumber, numberExeption)));
	  }
 }
@@ -526,32 +526,47 @@
 WhenPassArgToAdd
+PositiveNumbers
 ItShouldReturn()
@@ -560,32 +560,32 @@
 houldReturn() %7B%0A
-
 %09%09Calculator cal
@@ -918,32 +918,46 @@
 WhenPassArgToAdd
+NegativNumbers
 ItShouldReturn()
@@ -1731,32 +1731,47 @@
 henPassArgToTake
+PositiveNumbers
 ItShouldReturn()
@@ -2125,32 +2125,47 @@
 henPassArgToTake
+NegativeNumbers
 ItShouldReturn()
@@ -2943,32 +2943,47 @@
 henPassArgToMult
+PositiveNumbers
 ItShouldReturn()
@@ -3338,32 +3338,47 @@
 henPassArgToMult
+NegativeNumbers
 ItShouldReturn()
@@ -4155,32 +4155,47 @@
 henPassArgToShar
+PositiveNumbers
 ItShouldReturn()
@@ -4516,32 +4516,32 @@
 e numbers.%0A%09 */%0A
-
 %09public void tes
@@ -4550,32 +4550,47 @@
 henPassArgToShar
+NegativeNumbers
 ItShouldReturn()

add Mod