Multiplying mocked object method parameters

Viewed 30
public class Card
{

public double roundMoney(double currencyValue , int digits) {
//some logic for rounding which includes heavy service calling
} 

}

Now I want to mock the class and whenever the roundMoney methods is called with parameters I want it to return the product of the parameters

Card mycard = mock(Card.class);
when(mycard.roundMoney(anyDouble(), anyInt()).thenReturn( anyDouble() * anyInt() ));

How can I achieve this?

1 Answers
Related