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