0
嗨我有一个简单的方法,其中它需要一个字符串作为参数(域名// firstname.lastname)并取出(domainname //)并返回字符串作为firstname.lastname。单元测试方法ASP.NET帮助?
我需要为以下情况进行单元测试。
- 检查单斜杠(域名/ firstname.lastname)
- 检查空字符串
- 检查NULL值
- 检查wheather字符串包含//或不
我写了以下内容,但对我来说没有任何意义,因为这是完全错误的。
#region Checking for null value
[TestMethod]
public void CheckForNullValueTest()
{
string expected = "";
string source = @"domainname//hari.gillala";
string actual = Function.RemoveSlash(source);
assert.Equal(expected, actual);
}
#endregion
#region Checking for empty
[TestMethod]
public void CheckForEmptyValueTest()
{
string expected = string.empty;
string source = @"domainname//hari.gillala";
string actual = Function.RemoveSlash(source);
assert.Equal(expected, actual);
}
#endregion
#region Checking for singleslash
[TestMethod]
public void CheckForEmptyValueTest()
{
string expected = @"domainname/hari.gillala";
string source = "domainname//hari.gillala";
string actual = Function.RemoveSlash(source);
assert.Equal(expected, actual);
}
#endregion
#region Checking for Doubleslash
[TestMethod]
public void CheckForEmptyValueTest()
{
string expected = @"domainname//hari.gillala";
string source = "domainname//hari.gillala";
string actual = Function.RemoveSlash(source);
assert.Equal(expected, actual);
}
#endregion
我知道我完全错了,但有些可以帮助我理解,怎么写,有什么错误。感谢您的耐心
非常感谢 哈日
什么是你Function.RemoveSlash(源)的功能是什么样子? – gbs 2011-05-20 18:48:35
它需要domainname \\ hari.gillalla并给出hari.gillala – 2011-05-20 19:25:49
但是如果它为null/string.Empty会返回什么? – gbs 2011-05-20 19:31:12