import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.*;

public class ArrazTest {

    Arraz a = new Arraz();

    @Test
    public void sumValuesOfArrayIntTest1(){
        //Given

        int arr [] = {4,32,1,4};


        //When
        // 41

        int actual = a.sumValuesOfArrayInt(arr);

        //Then
        Assert.assertEquals(41,actual);

    }
    @Test
    public void sumValuesOfArrayIntTestNegative2(){
        //Given

        int arr [] = {-6,43,10,-3};


        //When
        // 44
        int actual = a.sumValuesOfArrayInt(arr);
        //Then

        Assert.assertEquals(44,actual);

    }

    @Test
    public void sumValuesOfArrayDoubleTest1(){

        //Given

        double arr [] = {6.0,43.4,10.3,-3.6};
        double value = 0;


        Double actual = a.sumValuesOfArrayDouble(arr);


        //Then
        Assert.assertEquals(55.0,actual);
    }

    @Test
    public void sumValuesOfArrayDoubleTest2(){

        //Given

        double arr [] = {-65,4.4,3.4,-3.6};
        double value = 0;


        Double actual = a.sumValuesOfArrayDouble(arr);


        //Then
        Assert.assertEquals(-59.0,actual);
    }

    @Test
    public void getTheAvgInt(){
        //Given

        int  arr [] = {65,4,4,3,36};


        //When

        int actual = a.getTheAvgInt(arr);

        //Then
        Assert.assertEquals(22,actual);
    }

    @Test
    public void getTheAvgInt2(){
        //Given

        int  arr [] = {6,4,4,-399,36};
        int value;

        //When

        value = a.sumValuesOfArrayInt(arr);

        int actual = value / arr.length ;

        //Then
        Assert.assertEquals(-69,actual);
    }

    @Test
    public void getTheAvgDoubTest(){
        //Given

        double arr [] = {6.5,0.4,45,3.0,36};


        //When

        double actual = a.getTheAvgDoub(arr);

        //Then
        Assert.assertEquals(18.0,actual);
    }

    @Test
    public void getTheAvgDoubTest2(){
        //Given

        double arr [] = {-6.5,0.4,-890,3050.0,36};


        //When

        double actual = a.getTheAvgDoub(arr);

        //Then
        Assert.assertEquals(438.2,actual);
    }


    @Test
    public void gettingThoseNullsTest(){
        //Given

        String arr [] = {"Connor","Frank",null,"Steven","Marshell"};


        //When

        Boolean actual = a.checkingForNull(arr);

        //Then
        Assert.assertTrue(actual);
    }

    @Test
    public void gettingThoseNoNullsTest(){
        //Given

        String arr [] = {"Carol","Frank","Steven","Marshell"};


        //When

        Boolean actual = a.checkingForNull(arr);

        //Then
        Assert.assertFalse(actual);
    }

    @Test
    public void testing_TheFibonacci() {

        long i = 44;


        System.out.println(a.theFibonacci(i));



    }

    @Test
    public void containsValueTestingFalse() {

        int[] arr = {1, 2, 3, 4};

        int value = 100;

       Boolean actual = a.containsValue(arr,value);


        Assert.assertFalse(actual);
    }
    @Test
    public void containsValueTestingTrue() {

        int[] arr = {1, 2, 3, 4};

        int value = 1;

        Boolean actual = a.containsValue(arr,value);


        Assert.assertTrue(actual);
    }

    @Test
    public void reverseArrayTest(){

        int [] arr = {5,6,7,8,9};
        int [] arr2 = {9,8,7,6,5};
        Boolean flag = null;


        int [] actual = a.reverseAnArray(arr);

        for (int i = 0; i < arr.length ; i++) {

            flag = actual[i] == arr2[i];

            System.out.print(actual[i]);
        }

        Assert.assertTrue(flag);

    }
    @Test
    public void reverseArrayTest2() {

        int[] arr = {5, 6, 7, -3, 9};
        int[] arr2 = {9, -3, 7, 6, 5};
        Boolean flag = null;


        int[] actual = a.reverseAnArray(arr);

        for (int i = 0; i < arr.length; i++) {

            flag = actual[i] == arr2[i];

            System.out.print(actual[i]);
        }

        Assert.assertTrue(flag);

        }


    }