org.fest.test
Interface EqualsHashCodeContractTestCase


public interface EqualsHashCodeContractTestCase

Understands verification of the equals/hashCode contract.

Author:
Alex Ruiz

Method Summary
 void should_have_consistent_equals()
          If two objects are equal, they must remain equal as long as they are not modified.
 void should_have_reflexive_equals()
          The object must be equal to itself, which it would be at any given instance; unless you intentionally override the equals method to behave otherwise.
 void should_have_symmetric_equals()
          If object of one class is equal to another class object, the other class object must be equal to this class object.
 void should_have_transitive_equals()
          If the first object is equal to the second object and the second object is equal to the third object; then the first object is equal to the third object.
 void should_maintain_equals_and_hashCode_contract()
          If two objects are equal, then they must have the same hash code, however the opposite is NOT true.
 void should_not_be_equal_to_null()
          Verifies that the implementation of the method equals returns false if a null is passed as argument.
 void should_not_be_equal_to_Object_not_being_of_same_type()
           
 

Method Detail

should_not_be_equal_to_Object_not_being_of_same_type

void should_not_be_equal_to_Object_not_being_of_same_type()

should_have_consistent_equals

void should_have_consistent_equals()
If two objects are equal, they must remain equal as long as they are not modified.


should_have_reflexive_equals

void should_have_reflexive_equals()
The object must be equal to itself, which it would be at any given instance; unless you intentionally override the equals method to behave otherwise.


should_have_symmetric_equals

void should_have_symmetric_equals()
If object of one class is equal to another class object, the other class object must be equal to this class object. In other words, one object can not unilaterally decide whether it is equal to another object; two objects, and consequently the classes to which they belong, must bilaterally decide if they are equal or not. They BOTH must agree.


should_have_transitive_equals

void should_have_transitive_equals()
If the first object is equal to the second object and the second object is equal to the third object; then the first object is equal to the third object. In other words, if two objects agree that they are equal, and follow the symmetry principle, one of them can not decide to have a similar contract with another object of different class. All three must agree and follow symmetry principle for various permutations of these three classes.


should_maintain_equals_and_hashCode_contract

void should_maintain_equals_and_hashCode_contract()
If two objects are equal, then they must have the same hash code, however the opposite is NOT true.


should_not_be_equal_to_null

void should_not_be_equal_to_null()
Verifies that the implementation of the method equals returns false if a null is passed as argument.



Copyright © 2008-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.