lundi 29 février 2016

Unit Testing Order of Enum

I have an enum that is ordered, representing sections of a grocery store in the order I traverse them.

enum Departments { Produce=0, Bulk=1, Deli=2, Frozen=3, NonFood=4, Bakery=5, DryGoods=6 }

Now I have some class representing items to get that have a name and a department:

class GroceryItem : IComparable<GroceryItem>
{
    string Name;
    Departments Department;
}

the proper sorting function sorts the grocery list alphabetically by Department, so I can minimize my traversal of the store.

Would it be valuable to unit test this enum for order, or should I be using some other data structure to hold department?

Aucun commentaire:

Enregistrer un commentaire