我是C#和单元测试的新手。我需要为switch语句编写一个单元测试,并且我不得不承认我已经经历了很多尝试寻找内容的页面。有谁能给我一些如何创建的提示?请在下面我的代码:
public static Message create(String body)
{
Message result = null;
switch (body.ToArray()[0])
{
case 'S':
//checking the regex for a sms message
Match matchS = Regex.Match(body, @"[S][0-9]{9}\+[0-9]{12}");
if (matchS.Success)
{
MessageBox.Show("This is SMS message");
//if the regex will match a sms_message class will be started
result = new Sms_Message(body.Substring(1));
}
//if the regex doesn't match the message should be displayed
else throw new Exception("I don't like content!!!!!!!!!!");
break;
case 'T':
//checking the regex for a tweet message
Match matchT …Run Code Online (Sandbox Code Playgroud)