Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Practical Test-Driven Development using C# 7

You're reading from   Practical Test-Driven Development using C# 7 Unleash the power of TDD by implementing real world examples under .NET environment and JavaScript

Arrow left icon
Product type Paperback
Published in Feb 2018
Publisher
ISBN-13 9781788398787
Length 442 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
John Callaway John Callaway
Author Profile Icon John Callaway
John Callaway
Clayton Hunt Clayton Hunt
Author Profile Icon Clayton Hunt
Clayton Hunt
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Why TDD is Important FREE CHAPTER 2. Setting Up the .NET Test Environment 3. Setting Up a JavaScript Environment 4. What to Know Before Getting Started 5. Tabula Rasa – Approaching an Application with TDD in Mind 6. Approaching the Problem 7. Test-Driving C# Applications 8. Abstract Away Problems 9. Testing JavaScript Applications 10. Exploring Integrations 11. Changes in Requirements 12. The Legacy Problem 13. Unraveling a Mess 14. A Better Foot Forward 15. Other Books You May Enjoy

Life sometimes hands you lemons

While I hope you never receive code this bad, we are going to walk through what is needed to turn even this into readable, maintainable, and fully tested code. The best part, the part you aren't going to believe, is that transforming this code is actually safe and fairly easy.

Getting started

In any code situation like this, the first thing we must do is remove the code in question from the environment where we have no control. In this case, we can't test the code if it is sitting in Program.main. So, let's grab the whole thing and put it into a class named Mastermind. We will have a single function named Play that will run the game. This is considered a safe refactoring, because...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime