TP #4: October 11th – Testing – Refactoring – Injection
Please take some to read and discover how the code from the project “PokerHandsRanker” is
organized. This code is organized between many classes, each having a separate and define
role. These classes are organized as “micro-services” and injected with calling classes using
dependency injection. All these classes respect the S.O.L.I.D. principles.
Question’s part (I expect a document with the answer):
1. What is the purpose of this code in a few lines?
2. Create a small UML diagram of the link between these classes. You can use an online
UML diagram editor to generate an image.
3. What are micro-services?
4. What is the goal of S.O.L.I.D. principles (not the definition)?
5. What is Dependency Injection? In what class is it done?
6. Explain to a manager (without technical terms) why tests are important and why
testing something that works is crucial on the long term.
7. What is refactoring? Why is it useful?
a. Find 3 ways you could expand this code to add more functionalities.
b. Choose a method that you would refactor. Why? What is the benefice of testing
this method first ?
Requirements:
1. Using NUnit, NSubstitute and NFluent, write the missing tests in the
PokerHandsRankerTests. What tests could you add?
2. Refactor this code, to:
a. Choose the number of players, up to 8.
b. Play with more than one deck of cards, up to 4.
c. (Optional) Have the correct names of hand displayed in HandPrinterService
(line 18) using another micro-service and dependency injection.