use*_*777 5 .net wcf unit-testing
我已经创建了一个WCF服务,并试图测试其中一个方法.我右键单击了WCF服务方法并选择了创建单元测试.
它创建了一个新的测试项目并创建了一个单元测试.
我试图运行测试项目,但我不确定应该是什么UrlToTest值?我把url放到了服务上.
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\VS Projects\\NetBranch4\\" +
"MobileCheckCapture\\MobileCheckCapture", "/")]
// [UrlToTest("http://localhost:45651/")]
[UrlToTest("http://localhost/mobilecc/mobilecc.svc")]
public void AuthenticateUserTest()
{
// TODO: Initialize to an appropriate value
MobileCC target = new MobileCC();
// TODO: Initialize to an appropriate value
string authenticateRequest = string.Empty;
// TODO: Initialize to an appropriate value
string expected = string.Empty;
string actual;
actual = target.AuthenticateUser(authenticateRequest);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
Run Code Online (Sandbox Code Playgroud)
小智 3
HostType、AspNetDevelopmentServerHost 和 UrlToTest 是用于 ASP.NET UnitTest 的参数,而不是用于 WCF 的参数。只需注释这些属性,设置输入参数和断言并运行测试。
[TestMethod()]
public void AuthenticateUserTest()
{
MobileCC target = new MobileCC(); // TODO: Initialize to an appropriate value
string authenticateRequest = string.Empty; // TODO: Initialize to an appropriate value
string expected = string.Empty; // TODO: Initialize to an appropriate value string actual;
actual = target.AuthenticateUser(authenticateRequest);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。