Appropriate use of Tuple <> in unit test?

When writing a set of unit tests (for an existing legacy component), I need a way to link the list of error codes (which will be returned by the service that I was mocking) and the list of corresponding error messages (which my component checks will return).

Usage seems to be List<Tuple<string, string>>a good easy way to define this association.

var errorCodesAndMessages = new List<Tuple<string, string>>
{
    Tuple.Create("CODE1", "Error message 1"),
    Tuple.Create("CODE2", "Error message 2")
    // etc...
};

In my unit test, I will then scroll through errorCodesAndMessages, setting up my mocked service to return the nth error code, and claiming that the component under test returns the nth error message.

Is it good - or abuse - Tuple<>?

Edit

, Dictionary<string, string> . . , , ( - ) (, , )

Tuple<>?

Tuple.Create("CODE1", "User error message", "Technical error message")
+3
2

Tuple , , , , - .

Dictionary<string, ErrorCodeDetails>
+4

, Dictionary<string, string> , , . Dictionary .

var errorCodesAndMessages = new Dictionary<string, string>()
{
    { "CODE1", "Error message 1" },
    { "CODE2", "Error message 2" },
    // etc...
};

.

+4

All Articles