Hi I have a simple method, where It takes a string as parameter (domainname//firstname.lastname) and takes out (domainname//) and returns string as just firstname.lastname.
I need to unit test for the following case.
- check for single slash (domainname/firstname.lastname)
- Check for empty string
- Check for null value
- Check wheather the string contains // or not
I wrote the following but it does not make any sense to me, coz this is completely wrong.
#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
I know I am completely wrong, but some can help me to understand, how to write, what are the mistakes. thanks for the patience
Many Thanks
Hari
Your source should be a value you are performing test for:
E.g. Checking for double slash your source string should contain //.
Here’s a Sample test (NUnit).
The Class that the Test uses: