I already have a test setup up for this function but I would like to know if it's the best way to go about it. I have a method like this:
public static string RunTableInfoCommand(IMapinfoWrapper wrapper,
TableInfoEnum infoToReturn)
{
//pass the int value of infoToReturn to underlying COM object eg wrapper.
}
the TableInfoEnum looks like this(shortened version):
public enum TableInfoEnum
{
TAB_INFO_NAME = 1,
TAB_INFO_NUM = 2,
TAB_INFO_TYPE = 3,
TAB_INFO_NCOLS = 4,
TAB_INFO_MAPPABLE = 5,
TAB_INFO_READONLY = 6,
TAB_INFO_TEMP = 7
}
When I pass the enum into the COM object it will return different string results based on the enum value. eg
TAB_INFO_NAME = "Water_Mains"
TAB_INFO_NUM = "1"
The COM object will always return a string just different values based on the enum value.
How would I test that my RunTableInfoCommand is working properly, so far I have a test like this:
public void RunTableInfoCommandPassingTableNumberShouldReturnExpectedName()
{
string ExpectedCommand = "TableInfo(1,{0})".FormatWith((int)TableInfoEnum.TAB_INFO_NAME);
mockmapinfo.Expect(m => m.Evaluate(ExpectedCommand))
.Returns("Water_Mains");
string name = Table.RunTableInfoCommand(mockmapinfo.Object,
1,
TableInfoEnum.TAB_INFO_NAME);
Assert.AreEqual("Water_Mains", name);
}
It does work but I just feel like I'm missing something, how do you test for all the different enum types.