do one's homework
To prepare oneself with the relevant knowledge; to carry out the necessary research in advance.
As the hearing went on, Harradence impressed me. When the judge asked for his comment on an issue, Harradence had clearly done his homework and was never taken by surprise.