generalize dynamic mocking macro