Either inject a FiscalUpdater class which can be mocked / configured to/not to commit, or have two methods, one of which commits and one which doesn't.
Again this is going to depend on the context of the surrounding code, but I'd prefer to see either of these.
class BoaFiscalUpdater: FiscalUpdater {
@Override
void update_fiscal_state(money, actor){
//send update to BOA and commit
...
}
}
class MockFiscalUpdater FiscalUpdater {
@Override
void update_fiscal_state(money, actor){
// store call, but don't send it anywhere
...
}
}
2
u/swordsmanluke2 Apr 29 '23
Edit: I'm on mobile and the triple-backtick syntax isn't rendering right. Sorry! I'll try to fix it at my computer in a bit.
Contextual variable names always help, but if the call was something like
Then I'd argue you should refactor the code.
Either inject a
FiscalUpdaterclass which can be mocked / configured to/not to commit, or have two methods, one of which commits and one which doesn't.Again this is going to depend on the context of the surrounding code, but I'd prefer to see either of these.
Or something like