Implement doSample() and add a working test.