1 package com.mockobjects.examples.calcserver; 2 3 import com.mockobjects.ExpectationValue; 4 import com.mockobjects.MockObject; 5 6 public class MockCalculator extends MockObject implements IntCalculator { 7 private int myResult; 8 private ExpectationValue myValue1 = new ExpectationValue("value1"); 9 private ExpectationValue myValue2 = new ExpectationValue("value2"); 10 private ExpectationValue myOperation = new ExpectationValue("operation"); 11 private String myBadOperation; 12 13 14 17 public MockCalculator() { 18 super(); 19 } 20 21 22 public int calculate(int value1, int value2, String operation) throws CalculatorException { 23 myValue1.setActual(value1); 24 myValue2.setActual(value2); 25 myOperation.setActual(operation); 26 return myResult; 27 } 28 29 30 public void setExpectedCalculation(int value1, int value2, String operation) { 31 myValue1.setExpected(value1); 32 myValue2.setExpected(value2); 33 myOperation.setExpected(operation); 34 } 35 36 37 public void setupResult(int result) { 38 myResult = result; 39 } 40 41 42 public void setupThrowBadOperation(String opName) { 43 myBadOperation = opName; 44 } 45 46 47 public void verify() { 48 myValue1.verify(); 49 myValue2.verify(); 50 myOperation.verify(); 51 } 52 } | Popular Tags |