#region 附加测试属性
//编写测试时,可使用以下附加属性:
#region InitTest
public static string invokeusername;
public static string invokeuserpwd;
public static string username;
public static string userIP;
public static string ConnKey;
public static string ConnValue;
public static int rowCount;
public static DateTime ldNow;
public static string Languages;
#endregion
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
invokeusername = "Nasdasdas";
invokeuserpwd = "jasdadasdasda";
username = "downmoon";
userIP = "10.103.33.6";
ConnKey = "";
ConnValue = "";
rowCount = 0;
ldNow = DateTime.Now;
Languages = "cn";
}
[ClassCleanup()]
public static void MyClassCleanup()
{
invokeusername = null;
invokeuserpwd = null;
}
#endregion
#region HelloWorld () 的测试
/// <summary>
///HelloWorld () 的测试
///</summary>
[TestMethod]
public void HelloWorldTest()
{
try
{
PassPortWebService target =new PassPortWebService() ;
target.SecuritySoapHeaderValue = new TestAPI.PassPort.SecuritySoapHeader();
target.SecuritySoapHeaderValue.InvokeUserName = invokeusername;
target.SecuritySoapHeaderValue.InvokeUserPwd = invokeuserpwd;
string str = target.HelloWorld();
Console.WriteLine(str);//Console.WriteLine("Result:" + str);
Assert.AreEqual(str, "Suceed!", false);
}
catch (Exception ex)
{
Assert.Fail("单元测试生成错误: " + ex.Message);
////Console.WriteLine(ex.Message);
}
} #endregion
//编写测试时,可使用以下附加属性:
#region InitTest
public static string invokeusername;
public static string invokeuserpwd;
public static string username;
public static string userIP;
public static string ConnKey;
public static string ConnValue;
public static int rowCount;
public static DateTime ldNow;
public static string Languages;
#endregion
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
invokeusername = "Nasdasdas";
invokeuserpwd = "jasdadasdasda";
username = "downmoon";
userIP = "10.103.33.6";
ConnKey = "";
ConnValue = "";
rowCount = 0;
ldNow = DateTime.Now;
Languages = "cn";
}
[ClassCleanup()]
public static void MyClassCleanup()
{
invokeusername = null;
invokeuserpwd = null;
}
#endregion
#region HelloWorld () 的测试
/// <summary>
///HelloWorld () 的测试
///</summary>
[TestMethod]
public void HelloWorldTest()
{
try
{
PassPortWebService target =new PassPortWebService() ;
target.SecuritySoapHeaderValue = new TestAPI.PassPort.SecuritySoapHeader();
target.SecuritySoapHeaderValue.InvokeUserName = invokeusername;
target.SecuritySoapHeaderValue.InvokeUserPwd = invokeuserpwd;
string str = target.HelloWorld();
Console.WriteLine(str);//Console.WriteLine("Result:" + str);
Assert.AreEqual(str, "Suceed!", false);
}
catch (Exception ex)
{
Assert.Fail("单元测试生成错误: " + ex.Message);
////Console.WriteLine(ex.Message);
}
} #endregion
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货