1 3 package org.jmock.expectation; 4 5 6 public class ExpectationValue extends AbstractExpectation 7 { 8 private Object myExpectedValue; 9 private Object myActualValue; 10 11 public ExpectationValue( String name ) { 12 super(name); 13 clearActual(); 14 } 15 16 public void clearActual() { 17 myActualValue = new Null("Nothing"); 18 } 19 20 public void setActual( int aValue ) { 21 setActual(new Integer (aValue)); 22 } 23 24 public void setActual( long aValue ) { 25 setActual(new Long (aValue)); 26 } 27 28 public void setActual( double aValue ) { 29 setActual(new Double (aValue)); 30 } 31 32 public void setActual( Object aValue ) { 33 myActualValue = aValue; 34 if (shouldCheckImmediately()) { 35 verify(); 36 } 37 } 38 39 public void setActual( boolean aValue ) { 40 setActual(new Boolean (aValue)); 41 } 42 43 public void setExpected( int aValue ) { 44 setExpected(new Integer (aValue)); 45 } 46 47 public void setExpected( long aValue ) { 48 setExpected(new Long (aValue)); 49 } 50 51 public void setExpected( double aValue ) { 52 setExpected(new Double (aValue)); 53 } 54 55 public void setExpected( Object aValue ) { 56 myExpectedValue = aValue; 57 setHasExpectations(); 58 } 59 60 public void setExpected( boolean aValue ) { 61 setExpected(new Boolean (aValue)); 62 } 63 64 public void setExpectNothing() { 65 setExpected(new Null("Nothing")); 66 myActualValue = myExpectedValue; 67 } 68 69 public void verify() { 70 assertEquals("did not receive the expected Value.", 71 myExpectedValue, 72 myActualValue); 73 } 74 } 75 | Popular Tags |