import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;


public class ArrazTest {
    Arraz arraz = new Arraz();

    @Test
    public void sumValuesOfArray1() {
        Integer[] array = {1, 2, 3};
        int expectedSum = 6;

        int actualSum = arraz.sumValuesOfArray(array);

        Assert.assertEquals(expectedSum, actualSum);
    }

    @Test
    public void sumValuesOfArray2() {
        Integer[] array = {1, 2, 3, 4};
        int expectedSum = 10;

        int actualSum = arraz.sumValuesOfArray(array);

        Assert.assertEquals(expectedSum, actualSum);
    }

    @Test
    public void sumDoublesOfArray1() {
        Double[] array = {1.5, 2.0, 3.5};
        double expectedSum = 7.0;

        double actualSum = arraz.sumDoublesOfArray(array);

        Assert.assertEquals(expectedSum, actualSum);

    }

    @Test
    public void sumDoublesOfArray2() {
        Double[] array = {2.0, 3.5, 1.0};
        double expectedSum = 6.5;

        double actualSum = arraz.sumDoublesOfArray(array);

        Assert.assertEquals(expectedSum, actualSum);
    }

    @Test
    public void averageOfArray1() {
        Integer[] array = {1, 2, 3};
        int expectedAverage = 2;

        int actualAverage = arraz.averageOfArray(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void averageOfArray2() {
        Integer[] array = {4, 5, 6};
        int expectedAverage = 5;

        int actualAverage = arraz.averageOfArray(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void doubleAverageOfArrayTest() {
        Double[] array = {1.5, 2.5, 3.5};
        double expectedAverage = 2.5;

        double actualAverage = arraz.doubleAverageOfArray(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void doubleAverageOfArrayTest2() {
        Double[] array = {1.5, 2.5, 3.5, 2.0};
        double expectedAverage = 2.375;

        double actualAverage = arraz.doubleAverageOfArray(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void containsValueTrue() {
        Integer[] array = {1, 2, 3};

        boolean actualOutput = arraz.containsValue(array, 2);

        Assert.assertTrue(actualOutput);
    }

    @Test
    public void containsValueFalse() {
        Integer[] array = {1, 2, 3};

        boolean actualOutput = arraz.containsValue(array, 65);

        Assert.assertFalse(actualOutput);
    }

    @Test
    public void reverseArrayTest1() {
        Integer[] array = {1, 2, 3};
        Integer[] expectedOutput = {3, 2, 1};

        Integer[] actualOutput = arraz.reverseArray(array);

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void reverseArrayTest2() {
        Integer[] array = {3, 2, 1};
        Integer[] expectedOutput = {1, 2, 3};

        Integer[] actualOutput = arraz.reverseArray(array);

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void OddEvenOfArrayTestEvens() {
        Integer[] array = {3, 2, 7};

        OddEven oe = arraz.getOddEvensOfArray(array);
        int expectedOutput = 1;
        int actualOutput = oe.getEvens();

        Assert.assertEquals(expectedOutput, actualOutput);

    }

    @Test
    public void OddEvenOfArrayTestOdds() {
        Integer[] array = {3, 2, 7};

        OddEven oe = arraz.getOddEvensOfArray(array);
        int expectedOutput = 2;
        int actualOutput = oe.getOdds();

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void findIndexOfTest1() {
        Integer[] array = {1, 2, 3};

        int expectedIndex = 2;
        int actualIndex = arraz.findIndexOf(array, 3);

        Assert.assertEquals(expectedIndex, actualIndex);

    }

    @Test
    public void findIndexOfTest2() {
        Integer[] array = {1, 2, 4};

        int expectedIndex = -1;
        int actualIndex = arraz.findIndexOf(array, 34);

        Assert.assertEquals(expectedIndex, actualIndex);

    }

    @Test
    public void copyArrayByIteratorTest1(){
        Integer[] array = {1,2,4};
        Integer[] expectedArray = {1,2,4};

        Integer[] actualArray = arraz.copyArrayByIterator(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void copyArrayByIteratorTest2(){
        Integer[] array = {1,2,4,6,7,8};
        Integer[] expectedArray = {1,2,4,6,7,8};

        Integer[] actualArray = arraz.copyArrayByIterator(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void copyArrayByLoopTest1() {
        Integer[] array = {1, 5, 7};

        Integer[] expectedArray = {1, 5, 7};
        Integer[] actualArray = arraz.copyArrayByLoop(array);

        Assert.assertEquals(expectedArray, actualArray);

    }

    @Test
    public void copyArrayByLoopTest2() {
        Integer[] array = {1, 5, 7, 2};

        Integer[] expectedArray = {1, 5, 7, 2};
        Integer[] actualArray = arraz.copyArrayByLoop(array);

        Assert.assertEquals(expectedArray, actualArray);

    }

    @Test
    public void removeElementFromArrayTest1() {
        Integer[] array = {1, 5, 7, 2};

        Integer[] expectedArray = {1, 5, 2};
        Integer[] actualArray = arraz.removeElementFromArray(array, 7);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void removeElementFromArrayTest2() {
        Integer[] array = {1, 5, 7, 2};

        Integer[] expectedArray = {1, 5, 7};
        Integer[] actualArray = arraz.removeElementFromArray(array, 2);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertIntoArrayTest1() {
        Integer[] array = {1, 5, 7, 2};

        Integer[] expectedArray = {1, 3, 5, 7, 2};
        Integer[] actualArray = arraz.insertIntoArrayAt(array, 3, 1);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertIntoArrayTest2() {
        Integer[] array = {1, 5, 7, 2};

        Integer[] expectedArray = {1, 5, 7, 6, 2};
        Integer[] actualArray = arraz.insertIntoArrayAt(array, 6, 3);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void findMinMaxOfArrayTest1() {
        Integer[] array = {1, 2, 3, -1};

        MaxMin mm = arraz.findMaxMinOfArray(array);
        int expectedMax = 3;
        int actualMax = mm.getMax();

        Assert.assertEquals(expectedMax, actualMax);
    }

    @Test
    public void findMinMaxOfArrayTest2() {
        Integer[] array = {1, 2, 3, -1};

        MaxMin mm = arraz.findMaxMinOfArray(array);
        int expectedMin = -1;
        int actualMin = mm.getMin();

        Assert.assertEquals(expectedMin, actualMin);
    }

    @Test
    public void removeDupesTest1(){
        Integer[] array = {1,2,3,3,4,5,5};
        Integer[] expectedArray = {1,2,3,4,5};

        Integer[] actualArray = arraz.removeDupesFromArray(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void removeDupesTest2(){
        Integer[] array = {1,2,3,3,4,5,5,6,6};
        Integer[] expectedArray = {1,2,3,4,5,6};

        Integer[] actualArray = arraz.removeDupesFromArray(array);

        Assert.assertEquals(expectedArray, actualArray);
    }


    @Test
    public void find2ndLargest1() {
        double[] array = {1.25, 1.5, 2.0};

        double expectedOutput = 1.5;
        double actualOutput = arraz.find2ndLargestValueFromArray(array);

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void find2ndLargest2() {
        double[] array = {1.25, 3.0, 2.0};

        double expectedOutput = 2.0;
        double actualOutput = arraz.find2ndLargestValueFromArray(array);

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void arrayToArrayListTest1() {
        Integer[] array = {1, 2, 4};


        int expectedOutput = 3;
        int actualOutput = arraz.makeMeAnArrayListFromArray(array).size();

        Assert.assertEquals(expectedOutput, actualOutput);
    }

    @Test
    public void arrayToArrayListTest2(){
    Integer[] array = {1, 2, 4, 6, 7};


    int expectedOutput = 5;
    int actualOutput = arraz.makeMeAnArrayListFromArray(array).size();

        Assert.assertEquals(expectedOutput,actualOutput);
    }

    @Test
    public void ArrayListToArrayTest1(){
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(2);
        list.add(4);
        list.add(7);

        int expectedOutput = 3;
        int actualOutput = arraz.makeMeAnArrayFromArrayList(list).length;

        Assert.assertEquals(expectedOutput, actualOutput);

    }

    @Test
    public void ArrayListToArrayTest2(){
        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(2);
        list.add(3);
        list.add(7);
        list.add(9);

        int expectedOutput = 4;
        int actualOutput = arraz.makeMeAnArrayFromArrayList(list).length;

        Assert.assertEquals(expectedOutput, actualOutput);

    }

    @Test
    public void averageWOMaxMinTest1(){
        Integer[] array = {0,2,2,4};
        int expectedAverage = 2;

        int actualAverage = arraz.averageArrayWithoutMaxMin(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void averageWOMaxMinTest2(){
        Integer[] array = {0,1,2,2,4,5};
        int expectedAverage = 2;

        int actualAverage = arraz.averageArrayWithoutMaxMin(array);

        Assert.assertEquals(expectedAverage, actualAverage);
    }

    @Test
    public void check2ArraysEqualTrue(){
        Integer[] array1 = {1,2,3};
        Integer[] array2 = {1,2,3};

        boolean actualOutput = arraz.check2ArraysForEqual(array1, array2);

        Assert.assertTrue(actualOutput);

    }

    @Test
    public void check2ArraysEqualFalse(){
        Integer[] array1 = {1,2,4};
        Integer[] array2 = {1,2,3};

        boolean actualOutput = arraz.check2ArraysForEqual(array1, array2);

        Assert.assertFalse(actualOutput);

    }

    @Test
    public void arrayHas65and77True(){
        Integer[] array = {1,2,65,77};

        boolean actualOutput = arraz.arrayHas65and77(array);

        Assert.assertTrue(actualOutput);
    }

    @Test
    public void arrayHas65and77False(){
        Integer[] array = {1,2,3,4};

        boolean actualOutput = arraz.arrayHas65and77(array);

        Assert.assertFalse(actualOutput);
    }

    @Test
    public void total30True(){
        Integer[] array = {1,2,10,5,10,7,10};

        boolean actualOutput = arraz.theTotalofTensIs30(array);
        Assert.assertTrue(actualOutput);
    }

    @Test
    public void total30False(){
        Integer[] array = {1,2,10,57,10};

        boolean actualOutput = arraz.theTotalofTensIs30(array);
        Assert.assertFalse(actualOutput);
    }

    @Test
    public void findSmallestTest1(){
        Integer[] array = {8,1,7,3,4,10};
        Integer[] expectedArray = {1,3};

        Integer[] actualArray = arraz.findSmallestAndSecondSmallest(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void findSmallestTest2(){
        Integer[] array = {8,1,7,3,10,0};
        Integer[] expectedArray = {0,1};

        Integer[] actualArray = arraz.findSmallestAndSecondSmallest(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void makeMeACopyPleaseTest1(){
        Integer[] array = {8,1,7,3,10,0};
        Integer[] expectedArray = {0,10,3,7,1,8};

        Integer[] actualArray = arraz.makeMeACopyPlease(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void makeMeACopyPleaseTest2(){
        Integer[] array = {7,3,10,0};
        Integer[] expectedArray = {0,10,3,7};

        Integer[] actualArray = arraz.makeMeACopyPlease(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void  removeLastItemAndCopyTest1(){
        Integer[] array = {7,3,10};
        Integer[] expectedArray = {7,3};

        Integer[] actualArray = arraz.removeLastItemAndCopy(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void  removeLastItemAndCopyTest2(){
        Integer[] array = {7,3,10,5,7,8};
        Integer[] expectedArray = {7,3,10,5,7};

        Integer[] actualArray = arraz.removeLastItemAndCopy(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void removeFirstItemAndCopyTest1(){
        Integer[] array = {7,3,10,5,7,8};
        Integer[] expectedArray = {3,10,5,7,8};

        Integer[] actualArray = arraz.removeFirstItemAndCopy(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void removeFirstItemAndCopyTest2(){
        Integer[] array = {10,5,7,8};
        Integer[] expectedArray = {5,7,8};

        Integer[] actualArray = arraz.removeFirstItemAndCopy(array);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertAtStartAndCopyTest1(){
        Integer[] array = {10,5,7,8};
        Integer[] expectedArray = {11,10,5,7,8};

        Integer[] actualArray= arraz.insertAtStartAndCopy(array, 11);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertAtStartAndCopyTest2(){
        Integer[] array = {11,10,5,7,8};
        Integer[] expectedArray = {12,11,10,5,7,8};

        Integer[] actualArray= arraz.insertAtStartAndCopy(array, 12);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertAtEndAndCopyTest1(){
        Integer[] array = {11,10,5,7,8};
        Integer[] expectedArray = {11,10,5,7,8,12};

        Integer[] actualArray= arraz.insertAtEndAndCopy(array, 12);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void insertAtEndAndCopyTest2(){
        Integer[] array = {11,10,5,7,8,12};
        Integer[] expectedArray = {11,10,5,7,8,12,13};

        Integer[] actualArray= arraz.insertAtEndAndCopy(array, 13);

        Assert.assertEquals(expectedArray, actualArray);
    }

    @Test
    public void sortArrayEvenOddsTest1(){
        Integer[] array = {11,10,5,7,8,12};
        Integer[] expectedArray = {10,8,12,11,5,7};

        Integer[] actualArray = arraz.sortArrayIntoEvensThenOdds(array);

        Assert.assertEquals(expectedArray, actualArray);

    }

    @Test
    public void sortArrayEvenOddsTest2(){
        Integer[] array = {11,10,5,7,12};
        Integer[] expectedArray = {10,12,11,5,7};

        Integer[] actualArray = arraz.sortArrayIntoEvensThenOdds(array);

        Assert.assertEquals(expectedArray, actualArray);

    }



}