O'Reilly logo

Practical Test-Driven Development using C# 7 by Clayton Hunt, John Callaway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Ready for enhancements

We are now to a point where the code makes enough sense that we can begin to work on our change requests. We have broken the random password generation portion of the code into its own method, so now we can work on it independently.

One of the first things we need to do is to stop using Random. Random is, by nature, unpredictable and outside of our control. We need a way to feed the number generation to verify that we can get the expected outputs when Random provides specific inputs.

We will extract an interface and mock class similar to what we did for Console. Here is the first round of tests, the mock class, and the interface that were created.

In the file RandomNumberTests.cs:

public class RandomNumberTests{ private ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required