How can I test some 'Insert method' in c# Unit test generated code, where I didn't get the actual and expected values
for insert method?
Can I create a actual and expected variables and run it?
Code:
[TestMethod()]
public void InsertCustomerTest()
{
string FirstName = "test"; // TODO: Initialize to an appropriate value
string LastName = "test"; // TODO: Initialize to an appropriate value
string Password = "test"; // TODO: Initialize to an appropriate value
string Email = "[email protected]"; // TODO: Initialize to an appropriate value
string Address = "test"; // TODO: Initialize to an appropriate value
string City = "test"; // TODO: Initialize to an appropriate value
string ZipCode = "test"; // TODO: Initialize to an appropriate value
int CountryId = 20; // TODO: Initialize to an appropriate value
string Phone = "test"; // TODO: Initialize to an appropriate value
string Skype = "test"; // TODO: Initialize to an appropriate value
string AIM = "test"; // TODO: Initialize to an appropriate value
string Yahoo = "test"; // TODO: Initialize to an appropriate value
string MSN = "test"; // TODO: Initialize to an appropriate value
string MedicalConditions = "test"; // TODO: Initialize to an appropriate value
CustomerManager.InsertCustomer(FirstName, LastName, Password, Email, Address, City, ZipCode, CountryId, Phone, Skype, AIM, Yahoo, MSN, MedicalConditions);
Loading
Soft CornerPosted Mar 7, 2011, 5:05 AM
If your accepting Input from your web page then you can validate it using
Validation Controls , Example2
and if your passing all values as a hard coded then you will need to implement Validation Method for it in cs class
for e.g .. validation for email id :-
public static bool isEmail(string inputEmail)
{
inputEmail = NulltoString(inputEmail);
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
Validation for Mobile no. :-
private void ValidatePhoneNumber(string number)
{
Regex re = new Regex("^9[0-9]{9}");
if(re.IsMatch(number.Trim()) == false || number.Length>10)
{
MessageBox.Show("Invalid Indian Mobile Number !!");
}
}
like this u can do
Alice CoopePosted May 3, 2011, 2:11 AM
Soft CornerPosted Mar 8, 2011, 4:20 AM
Ana AnaPosted Mar 8, 2011, 4:16 AM
Soft CornerPosted Mar 8, 2011, 4:06 AM
you will need to write separate method for each types of input (As i told you in above post
like for emailID,phoneno.,acceptString,..etc ) in windows application.
Refer This :-
MSDN , Article
Ana AnaPosted Mar 8, 2011, 3:52 AM
Can you tell me how can I test above insert method in Windows app?
Ana AnaPosted Mar 7, 2011, 5:12 AM
Ana AnaPosted Mar 7, 2011, 4:51 AM
Soft CornerPosted Mar 7, 2011, 4:47 AM
Above code is in Web application or in Windows application?