Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Notice I am making use of ArrayUtils from the unit testing phase.

Fixture - Find Highest Number

...

Or Sort List (no reuse of CUT)

Code Block
languagejava
titleFindHighestNumberAndSortArrayFixture
linenumberstrue
package com.celestial.tdd.fitnesse.demo;

import com.celestial.tdd.demo.complete.ArrayUtils;
import com.celestial.tdd.demo.complete.EmptyArrayException;
import java.util.Arrays;

/**
 *
 * @author Selvyn
 */
public class FindHighestNumberAndSortArrayFixtureFindHighestNumberOrSortArrayFixture
{
    int[] arrayOfInts;
    
    public  void    setNumbers( String vals )
    {
        arrayOfInts = Arrays.stream(vals.split(","))
                 .mapToInt(Integer::parseInt)
                 .toArray();
    }
    
    public  int  ExpectedValue()
    {
        ArrayUtils cut = new ArrayUtils();
        
        try
        {
            return cut.findHighest(arrayOfInts);
        } catch (EmptyArrayException ex)
        {
            return -1;
        }
    }
    
    public  void    setNumbersList( int[] vals )
    {
        arrayOfInts = vals;
    }
    
    public  String SortedList()
    {
        ArrayUtils cut = new ArrayUtils();
        
        int[] intArray = cut.sortedArray( arrayOfInts );
        
        String temp =  Arrays.toString(intArray);
        temp = temp.replaceAll("[\\[\\s\\]]", "");

        return temp;
    }
}

Fixture - Find Highest Number And Sort List (reuse of CUT)

Code Block
languagejava
titleFindHighestNumberAndSortArrayFixture
linenumberstrue
package com.celestial.tdd.fitnesse.demo.v2;

import com.celestial.tdd.demo.complete.ArrayUtils;
import com.celestial.tdd.demo.complete.EmptyArrayException;
import java.util.Arrays;

/**
 *
 * @author Selvyn
 */
public class FindHighestNumberAndSortArrayFixture
{
    int[] arrayOfInts;
    ArrayUtils cut = new ArrayUtils();
    int highestValue = -1;
    String sortedInts = "";
    
    public  void    setNumbers( String vals )
    {
        arrayOfInts = Arrays.stream(vals.split(","))
                 .mapToInt(Integer::parseInt)
                 .toArray();
    }
    
    public  void    setNumbersList( int[] vals )
    {
        arrayOfInts = vals;
    }
    
    public void execute()
    {
        try
        {
            highestValue =  cut.findHighest(arrayOfInts);
            sortedInts = sortTheList();
        } catch (EmptyArrayException ex){}
    }

    private  String sortTheList()
    {
        int[] intArray = cut.sortArray( arrayOfInts );
        
        String temp =  Arrays.toString(intArray);
        temp = temp.replaceAll("[\\[\\s\\]]", "");

        return temp;
    }
    
    public  int  ExpectedValue()
    {
        return highestValue;
    }
    
    public  String SortedList()
    {
        return sortedInts;
    }
}