source code/instructions (pages 20 and 21): https://github.com/head-first-csharp/fourth-edition/blob/master/Downloadable_projects/Chapter_9_project.pdf
I am building the GoFish project from Ch9 of the HeadFirst C# (4th Edition) textbook and cannot figure out how their test is supposed to set the Deck object to a specific order without changing code outside of the test. The test is GameControllerTests.TestPlayRound().
It is a test for a GameController class that keeps an instance of GameState which has a Stock property that stores a Deck class instance. The test method is PlayRound() and it manages the player's turn and the other computer player's turns. It takes in the HumanPlayer, the player that the HumanPlayer asks a card value for, the value being asked, and the Stock from the gameState. The primary purpose of PlayRound() is to set GameController.Status. The test is applied to the result Status produced by the method.
I can build the code for the class but the test can't pass because it doesn't sufficiently account for the shuffled Deck in GameState which is shuffled at the GameController level in its constructor. The decisions made based on cards dealt and cards asked for produce a specific Status to check in the test.
GameState.Stock (Deck instance) is readonly and for good reason (you want the stock to be immutable yet still able to be dealt). If it was not I would set the Deck to the exact order of cards that I want in the the test, but this is not possible.
Is there a method for writing unit tests that would allow me to set private or readonly variables from outside of this method?
(I believe I may be referring to a clear-box test as opposed to my black-box testing that I'm doing for all other tests in this project. That may be the only other option than making the Stock publicly mutable. This issue may also be related to the tight coupling but I am a bit novice to confidently say that is the cause of this situation.)