Hey All I have a section of a script that is pretty simple and works but I am wondering the best way to rewrite it to be testable.
I could set up an individual test to make sure the correct pref string is returned but wondering if there is a less breakable way
public class PreferenceHelper
{
public Stringstring getItemPreferenceByNumber(int num)
{
switch (num)
{
case 0:
return Constant.Tree_Bark_Upgrade_One_Unlocked;
case 1:
return Constant.Tree_Bark_Upgrade_Two_Unlocked;
case 2:
return Constant.Tree_Bark_Upgrade_Three_Unlocked;
case 3:
return Constant.Extra_Coconut_Upgrade_One_Unlocked;
case 4:
return Constant.Extra_Coconut_Upgrade_Two_Unlocked;
case 5:
return Constant.Extra_Coconut_Upgrade_Three_Unlocked;
case 6:
return Constant.Grandpaps_Cane_Unlocked;
case 7:
return Constant.Bamboo_Staff_Unlocked;
case 8:
return Constant.Whackin_Bat_Unlocked;
case 9:
return Constant.Whackin_Mallet_Unlocked;
case 10:
return Constant.Whackin_Golf_Club_Unlocked;
case 11:
return Constant.Whackin_Hammer_Unlocked;
case 12:
return Constant.Sap_Bomb_Unlocked;
case 13:
return Constant.Crabby_Bomb_Unlocked;
case 14:
return Constant.Boombox_Unlocked;
case 15:
return Constant.CraboPolt_Unlocked;
case 16:
return Constant.Inflatable_Palm_Tree_Unlocked;
case 17:
return Constant.Big_Bomb_Unlocked;
default:
return "";
}
}
}