I have MaxHeap
class which provides all usual properties that one heap will do (ExtractMax, Add, Build). Now I want to test it, but in order to test it I need to work with the structure I am using it internally (array) in order to verify that heap property is not violated.
What is the correct way of doing this without messing with the Heap class API?
- Should I duplicate code and copy the
MaxHeap
class in my testing project with all needed information exposed? - Or perhaps add some protected indexer in
MaxHeap
class and test it with stub?(don't like this approach much since it leaves door to inherit my class and get access to that indexer which basically defeats the logic of not changing the API of theMaxHeap
)
Aucun commentaire:
Enregistrer un commentaire