csheets.ext.test
Class TestCase

java.lang.Object
  extended by csheets.core.formula.Formula
      extended by csheets.ext.test.TestCase
All Implemented Interfaces:
Expression, Serializable

public class TestCase
extends Formula
implements Serializable

Contains the information for a single test case, i.e. a single test case parameter for each of the precedents.

Author:
Staffan Gustafsson, Jens Schou, Einar Pehrson
See Also:
Serialized Form

Nested Class Summary
static class TestCase.ValidationState
          The validation states of a test case.
 
Constructor Summary
TestCase(TestableCell cell, Set<TestCaseParam> params)
          Creates a new test case for the given cell in the given spreadsheet.
 
Method Summary
 boolean equals(Object other)
          Returns whether the other object has the same parameters and cell as this has.
 Value evaluate()
          Evaluates the expression and returns the result.
 TestableCell getCell()
          Returns the cell to which the formula belongs.
 Set<TestCaseParam> getParams()
           
 TestCase.ValidationState getValidationState()
           
 int hashCode()
          Returns the hash code of the test case.
 boolean hasParam(TestCaseParam param)
          Test if the TestCase is based on a specified TestCaseParam.
 void setValidationState(TestCase.ValidationState state)
           
 
Methods inherited from class csheets.core.formula.Formula
accept, getExpression, getReferences, hasCircularReference, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestCase

public TestCase(TestableCell cell,
                Set<TestCaseParam> params)
Creates a new test case for the given cell in the given spreadsheet. The value of the test case is calculated by replacing the references in the cell's formula with the given set of test case parameters.

Parameters:
cell - the cell for which the test case is to be created
params - the set of test case parameters to use
Method Detail

getCell

public TestableCell getCell()
Description copied from class: Formula
Returns the cell to which the formula belongs.

Overrides:
getCell in class Formula
Returns:
the cell to which the formula belongs

evaluate

public Value evaluate()
Description copied from interface: Expression
Evaluates the expression and returns the result.

Specified by:
evaluate in interface Expression
Overrides:
evaluate in class Formula
Returns:
the result of the evaluation

getParams

public Set<TestCaseParam> getParams()
Returns:
the set of test case parameters that make up the test case

getValidationState

public TestCase.ValidationState getValidationState()
Returns:
Returns the ValidationState of the TestCase.

setValidationState

public void setValidationState(TestCase.ValidationState state)
Parameters:
state - Sets the ValidationState of the TestCase to the param's state.

hasParam

public boolean hasParam(TestCaseParam param)
Test if the TestCase is based on a specified TestCaseParam.

Parameters:
param - The TestCaseParam we want to know it the TestCase uses
Returns:
true if the TestCase uses param, otherwise false

equals

public boolean equals(Object other)
Returns whether the other object has the same parameters and cell as this has.

Overrides:
equals in class Object
Parameters:
other - the object to check for equality
Returns:
true if the objects are equal

hashCode

public int hashCode()
Returns the hash code of the test case.

Overrides:
hashCode in class Object
Returns:
the hash code of the test case.