I'm totally new to TDD and am using NUnit to write tests for a Card Game application in writing in C#.
Mostly its proving really useful, but there are some things I'd like to test, but don't wish to expose any public properties from which to do so.
For example, I'd like to be able to test that a new card deck consists of 4 suits, each with 13 cards. it might look something like:
[Test()]
public void ADeckOfCardsHas4Suits()
{
Game game = new Game();
Assert.AreEqual(4, game.Deck.SuitCount);
Assert.AreEqual(13, game.Deck.GetCards(Suit.Spades).Count)
}
With SuitCount returning something like:
return this.cards.Select(c => c.Suit).Distinct().Count();
And GetCards(Suit suit):
return this.cards.where(c => c.Suit == suit);
However I don't want to expose these properties or methods in the API to the UI (I may not even wish to expose Deck), but am not sure how I can test against them without making them public.
Are there any generally accepted ways of doing this?
Cheers
Stewart