Whilst writing a set of unit tests (for an existing legacy component), I wanted a way to associate a list of error codes (which will be returned by a service that I have mocked), and a list of corresponding error messages (which my component under test will return).
It seems that using a
List<Tuple<string, string>> is a nice simple way to define this association.
var errorCodesAndMessages = new List<Tuple<string, string>>
Tuple.Create("CODE1", "Error message 1"),
Tuple.Create("CODE2", "Error message 2")
In my unit test I can then loop through the
errorCodesAndMessages, setting up my mocked service to return the nth error code, and asserting that the component under test returns the nth error message.
Is this a good use of — or an abuse of —