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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;



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

    @Test
    public void test1SumValueOfArrayInt() {
        Integer[] spiffyHandyIntArray ={4, 5, 102, 6, -7, 12, -32, 92, 8};

        int expected = 190;
        int actual = arraz.sumValuesOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);


    }

    @Test
    public void test2SumValueOfArrayInt() {
        Integer[] spiffyHandyIntArray = { 4, 5, 6, -7, 12, -32, 92};

        int expecte = 80;
        int actual = arraz.sumValuesOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expecte, actual);


    }


    @Test
    public void test1SumValueOfArrayDouble() {
        double[] spiffyHandyDoubleArray = new double[]{1.0, 0.5, 3.6, 3.14159};


        double expecte = 8.24159;
        double actual = arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
        Assert.assertEquals(expecte, actual, 0.00001);


    }

    @Test
    public void test2SumValueOfArrayDouble() {
        double[] spiffyHandyDoubleArray = new double[]{1.0, 0.5, 3.6 - 0.8};


        double expecte = 4.3;
        double actual = arraz.sumDoublesOfArray(spiffyHandyDoubleArray);
        Assert.assertEquals(expecte, actual, 0.01);


    }

    @Test
    public void test1AverageOfArray() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
        int expected = 11;
        int actual = arraz.averageOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void test2AverageOfArray() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, 10};
        int expected = 6;
        int actual = arraz.averageOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void test1DoubleAverageOfArray() {
        double[] spiffyHandyIntArray = new double[]{4.3, 5.9, 6.09, 10.8};
        double expected = 6.77;
        double actual = arraz.doubleAverageOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual, 0.01);
    }

    @Test
    public void test2DoubleAverageOfArray() {
        double[] spiffyHandyIntArray = new double[]{8.0, 9.9, 8.009, 77.06};
        double expected = 25.742;
        double actual = arraz.doubleAverageOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual, 0.001);
    }


    @Test
    public void test1ContainsValue() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
        int num = -32;
        Assert.assertTrue(arraz.containValue(spiffyHandyIntArray, num));


    }

    @Test
    public void test2ContainsValue() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
        int num = 6;
        Assert.assertTrue(arraz.containValue(spiffyHandyIntArray, num));


    }


    @Test
    public void test1ReverseArray() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};

        Integer[] expected = {92, -32, 12, -7, 6, 5, 4};
        Integer[] actual = arraz.reverseArray(spiffyHandyIntArray);
         Assert.assertTrue(Arrays.equals(expected,actual));


    }

    @Test
    public void test2ReverseArray() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};

        Integer[] expected = {92, -32, 12, -7, 6, 5, 4};
        Integer[] actual = arraz.reverseArray(spiffyHandyIntArray);
         Assert.assertTrue(Arrays.equals(expected,actual));


    }

    @Test
    public void test1getOddEvensOfArray() {

        int[] spiffyHandyIntArray = {4, 5, 6};
        OddEven expected = new OddEven(5, 4);
        OddEven actual = arraz.getOddEvensOfArray(spiffyHandyIntArray);
        Assert.assertEquals( expected, actual);


    }

    @Test
    public void test2getOddEvensOfArray() {
        int[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92,};
        OddEven expected = new OddEven(-7, 12);
        OddEven actual = arraz.getOddEvensOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);


    }

    @Test
    public void test1FindIndexOff() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};

        int expected = 3;
        int actual = arraz.findIndexOf(spiffyHandyIntArray, -7);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void test2FindIndexOff() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        int expected = 0;
        int actual = arraz.findIndexOf(spiffyHandyIntArray, 4);
        Assert.assertEquals(expected, actual);
    }
    @Test
    public void test1FindValueAt(){
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        int expected = 12;
        int actual = arraz.findValueAt(spiffyHandyIntArray, 4);
        Assert.assertEquals(expected,actual);
    }@Test
    public void test2FindValueAt(){
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        int expected = -32;
        int actual = arraz.findValueAt(spiffyHandyIntArray, 5);
        Assert.assertEquals(expected,actual);
    }


    @Test
    public void test1CopyArrayByInterator() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        Integer[] expected = {4, 5, 6, -7, 12, -32, 92};
        Integer[] actual = arraz.copyArrayByInterator(spiffyHandyIntArray);

        Assert.assertEquals(expected, actual);


    }

    @Test
    public void test2CopyArrayByInterator() {
        Integer[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        Integer[] expected = {4, 5, 6, -7, 12, -32, 92};
        Integer[] actual = arraz.copyArrayByInterator(spiffyHandyIntArray);

        Assert.assertEquals(expected, actual);


    }

    @Test
    public void test1CopyArrayByLoop() {
        int[] spiffyHandyIntArray = {4, 5, 6, -7, 12, -32, 92};
        int[] expected = {4, 5, 6, -7, 12, -32, 92};
        int [] actual = arraz.copyArrayByloop(spiffyHandyIntArray);

        Assert.assertTrue(Arrays.equals(expected,actual));


    }

    @Test
    public void test2CopyArrayByLoop() {
        int[] spiffyHandyIntArray = {4, 5, 6};
        int[] expected = {4, 5, 6};
        int [] actual = arraz.copyArrayByloop(spiffyHandyIntArray);

        Assert.assertTrue(Arrays.equals(expected, actual));


    }
    @Test
    public void test1RemoveElementFromArray(){
        Integer[] spiffyHandyIntArray = {4, 5, 6};

        arraz.removeElemetFromArray(spiffyHandyIntArray, 2);
        Assert.assertFalse(arraz.containValue(spiffyHandyIntArray,2));
    }
    @Test
    public void test2RemoveElementFromArray(){
        Integer[] spiffyHandyIntArray = {4, 5, 6};
        int expected = 0;
        arraz.removeElemetFromArray(spiffyHandyIntArray, 6);
        Assert.assertEquals(arraz.findIndexOf(spiffyHandyIntArray,5), expected);
}

@Test
    public void test1InsertIntoArrayAt(){
    Integer[] spiffyHandyIntArray = {4, 5, 6};
    Integer  num = 8;
    int expected = 0;

    arraz.insertIntoArrayAt(spiffyHandyIntArray, num, 0);

    Assert.assertEquals(expected, arraz.findIndexOf(spiffyHandyIntArray, 8));

}
    @Test
    public void test2InsertIntoArrayAt() {
        Integer[] spiffyHandyIntArray = {4, 5, 6};
        Integer num = 7;
        int expected = 0;

        arraz.insertIntoArrayAt(spiffyHandyIntArray, num, 2);


        Assert.assertEquals(expected, arraz.findIndexOf(spiffyHandyIntArray, 8));
    }
    @Test
    public void test1FindMaxMinOfArray() {

        Integer[] spiffyHandyIntArray = {4, 5, 6};
        MaxMin expected = new MaxMin(6, 4);
        MaxMin actual = arraz.findMaxMinOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);
    }
    @Test
    public void test2FindMaxMinOfArray() {

        Integer[] spiffyHandyIntArray = {8,3,90};
        MaxMin expected = new MaxMin(90, 3);
        MaxMin actual = arraz.findMaxMinOfArray(spiffyHandyIntArray);
        Assert.assertEquals(expected, actual);
    }
@Test
    public void test1RemoveDupesFromArray(){
    Integer[] spiffyHandyIntArray = {8, 8, 3,90, 90,77,8};
    Integer [] expected = {8,3,90,77};
    Integer [] actual = arraz.removeDupesFromArray(spiffyHandyIntArray);
    Assert.assertTrue(Arrays.equals(expected,actual));
}

    @Test
    public void test2RemoveDupesFromArray(){
        Integer[] spiffyHandyIntArray = {-1,-1,22,66,22,8,90,90};
        Integer [] expected = {-1,22,66,8,90};
        Integer [] actual = arraz.removeDupesFromArray(spiffyHandyIntArray);
        Assert.assertTrue(Arrays.equals(expected,actual));
    }
    @Test
     public void test1find2ndLargestValueFromArray(){
        double[] spiffyHandyIntArray = {8.3, 8.7, 3.90, 90.77};
        double expected = 8.7;

        double actual = arraz.find2ndLargestValueFromArrayDouble(spiffyHandyIntArray);
         Assert.assertEquals(expected,actual, 0.001);
    }

    @Test
    public void test2find2ndLargestValueFromArray(){
        double[] spiffyHandyIntArray = {4.99,99.5,8.95};
        double expected = 8.95;

        double actual = arraz.find2ndLargestValueFromArrayDouble(spiffyHandyIntArray);
        Assert.assertEquals(expected,actual, 0.001);
    }
    @Test
   public void test1makeMeAnArrayListFromArray(){
        Integer[] spiffyHandyIntArray = {4,99,8,};
        List<Integer> list = new ArrayList<Integer>();
        list.add(4);
        list.add(99);
        list.add(8);
        List<Integer> actual = arraz.makeMeAnArrayListFromArray(spiffyHandyIntArray);

        Assert.assertEquals(list,actual);


    }
    @Test
    public void test2makeMeAnArrayListFromArray(){
        Integer[] spiffyHandyIntArray = {22,100,3};
        List<Integer> list = new ArrayList<Integer>();
        list.add(22);
        list.add(100);
        list.add(3);
        List<Integer> actual = arraz.makeMeAnArrayListFromArray(spiffyHandyIntArray);

        Assert.assertEquals(list,actual);


    }
    @Test
    public void test1MakeAnArrayFromList(){

        List<Integer> list = new ArrayList<Integer>();
        list.add(22);
        list.add(100);
        list.add(3);
        Integer [] expecte = {22,100,3};
       Integer [] actual = arraz.makeMeAnArrayFromArrayList(list);


        Assert.assertEquals(expecte,actual);


    }

    @Test
    public void test2MakeAnArrayFromList(){

        List<Integer> list = new ArrayList<Integer>();
        list.add(1);
        list.add(10);
        list.add(3);
        Integer [] expecte = {1,10,3};
        Integer [] actual = arraz.makeMeAnArrayFromArrayList(list);


        Assert.assertEquals(expecte,actual);


    }
    @Test
    public void test1check2ArraysForEqual(){
        int [] arr1 = {1,2,3};
        int [] arr2 = { 1,2,3};
        Assert.assertTrue(arraz.check2ArraysForEqual(arr1,arr2));
    }

    @Test
    public void test2check2ArraysForEqual(){
        int [] arr1 = {1,2,22,3,45};
        int [] arr2 = { 1,2,22,3,45};
        Assert.assertTrue(arraz.check2ArraysForEqual(arr1,arr2));
    }
    @Test
    public void test1averageArrayWithoutMaxMin(){
        Integer [] arr1 = {1,2,22,3,45,33};
        int expected = 9;
        int actual = arraz.averageArrayWithoutMaxMin(arr1);
        Assert.assertEquals(expected,actual);
    }
    @Test
    public void test2averageArrayWithoutMaxMin(){
        Integer [] arr1 = {1,2,3,4,33};
        int expected = 3;
        int actual = arraz.averageArrayWithoutMaxMin(arr1);
        Assert.assertEquals(expected,actual);
    }
    @Test
     public void test1arrayHas65and77(){
        Integer [] arr1 = {65,77};

        Assert.assertTrue(arraz.arrayHas65and77(arr1));

     }
    @Test
    public void test2arrayHas65and77(){
        Integer[] arr1 = {1,2,3,4,33};

        Assert.assertFalse(arraz.arrayHas65and77(arr1));

    }

    @Test
    public void test1theTotalOfTensIs30(){
        int [] arr1 = {1,20,10,4,10,5,6,10};
        Assert.assertTrue(arraz.theTotalofTensIs30(arr1));
    }
    @Test
    public void test2theTotalOfTensIs30(){
        int [] arr1 = {1,20,10,4,5,6,10};
        Assert.assertFalse(arraz.theTotalofTensIs30(arr1));
    }

    @Test
    public void test1findSmallerAndSecondSmaller(){
        Integer[] arr1 = {1,20,10,4,5,6,10};
        int expected = 14;
        int actual = arraz.findSmallerAndSecondSmaller(arr1);
        Assert.assertEquals(expected,actual);
    }
    @Test
    public void test2findSmallerAndSecondSmaller(){
        Integer[] arr1 = {7,20,10,4,5,6,10};
        int expected = 45;
        int actual = arraz.findSmallerAndSecondSmaller(arr1);
        Assert.assertEquals(expected,actual);
    }

   @Test
    public void test1RemoveLastItemAndCopy(){
       Integer[] arr1 = {1,20,10,4,5,6,10};
       Integer[] expected= {1,20,10,4,5,6};
       Integer [] actual = arraz.removeLastItemAndCopy(arr1);
       Assert.assertTrue(Arrays.equals(expected,actual));

   }
    @Test
    public void test2RemoveLastItemAndCopy(){
        Integer[] arr1 = {5,6,10};
        Integer[] expected= {5,6};
        Integer [] actual = arraz.removeLastItemAndCopy(arr1);
        Assert.assertTrue(Arrays.equals(expected,actual));

    }


    @Test
    public void test1RemoveFirstItemAndCopy() {
        Integer[] arr1 = {5, 6, 10};
        Integer[] expected = {6, 10};
        Integer[] actual = arraz.removeFirstItemAndCopy(arr1);
        Assert.assertTrue(Arrays.equals(expected, actual));

    }
    @Test
    public void test2RemoveFirstItemAndCopy() {
        Integer[] arr1 = { 6,10,88,9};
        Integer[] expected = {10,88,9};
        Integer[] actual = arraz.removeFirstItemAndCopy(arr1);
        Assert.assertTrue(Arrays.equals(expected, actual));

    }
    @Test
    public void test1InsertAtStatAndCopy() {
        Integer [] arr1 = {6,10,88,9};
        Integer num = 2;
        Integer [] expected = {2,6,10,88,9};
        Integer[] actual = arraz.insertAtStartAndCopy(arr1,num);
      Assert.assertEquals(expected, actual);

    }
    @Test
    public void test2InsertAtStatAndCopy() {
        Integer [] arr1 = {6,10,88,9};
        Integer num = 88;
        Integer [] expected = {88,6,10,88,9};
        Integer[] actual = arraz.insertAtStartAndCopy(arr1,num);
        Assert.assertEquals(expected, actual);

    }
    @Test
    public void test1InsertAtEndAndCopy() {
        Integer [] arr1 = {6,10,88,9};
        Integer num = 82;
        Integer [] expected = {6,10,88,9,82};
        Integer[] actual = arraz.insertAtEndAndCopy(arr1,num);
        Assert.assertEquals(expected, actual);

    }
    @Test
    public void test2InsertAtEndAndCopy() {
        Integer [] arr1 = {6,10,88,9};
        Integer num = 3;
        Integer [] expected = {6,10,88,9,3};
        Integer[] actual = arraz.insertAtEndAndCopy(arr1,num);
        Assert.assertEquals(expected, actual);

    }
    @Test
    public void test1SortArrayIntoEvensThenOdds(){
        Integer [] arr1 = {1,2,3,4,5,6};
        Integer[] expected = {2,4,6,1,3,5};
        Integer[] actual = arraz.sortArrayIntoEvensThenOdds(arr1);
        //System.out.println(Arrays.toString(actual));
        Assert.assertEquals(expected,actual);
    }
    @Test
    public void test2SortArrayIntoEvensThenOdds(){
        Integer [] arr1 = {7,22,33,44,5};
        Integer[] expected = {22,44,5,7,33};
        Integer[] actual = arraz.sortArrayIntoEvensThenOdds(arr1);
        //System.out.println(Arrays.toString(actual));
        Assert.assertEquals(expected,actual);
    }



}