Testing and throwing an exception if the command method is called with the wrong objects