Created
February 25, 2019 20:00
-
-
Save jonbodner/07e819c68103f79b5585e4cfbc8326b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CalcControllerTest { | |
@Test | |
public void result() { | |
CalcController c = new CalcController(new Calculator() { | |
@Override | |
public double process(String expression) { | |
if (expression.equals("1 + 1")) { | |
return 2; | |
} | |
if (expression.equals("+")) { | |
throw new CalculatorException("Invalid expression: +"); | |
} | |
throw new CalculatorException("Unexpected input: "+ expression); | |
} | |
}); | |
assertEquals("2.0", c.result("1 + 1")); | |
assertEquals("Invalid expression: +", c.result("+")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment