单元测试WCF方法 [英] Unit test WCF method
问题描述
我创建了一个WCF服务,并试图测试的方法之一。我右键点击了WCF服务的方法和选择创建单元测试。
它创建了一个新的测试项目,并创建一个单元测试。
我试图运行测试项目,但我不知道什么应该是 UrlToTest
价值?我已经把网址服务。
[TestMethod的()
[HOSTTYPE(ASP.NET)
[AspNetDevelopmentServerHost(C:\\ VS项目\\ NetBranch4 \\+
MobileCheckCapture \\ MobileCheckCapture,/)]
// [UrlToTest(的http://本地主机:45651 /)]
[UrlToTest(HTTP://localhost/mobilecc/mobilecc.svc)]
公共无效AuthenticateUserTest()
{
// TODO:初始化为合适的值
MobileCC目标=新MobileCC();
// TODO:初始化为合适的值
字符串的AuthenticateRequest =的String.Empty;
// TODO:初始化为合适的值
预计=的String.Empty串;
字符串的实际;
实际= target.AuthenticateUser(的AuthenticateRequest);
Assert.AreEqual(预期,实际值);
Assert.Inconclusive(验证这种测试方法的正确性。);
}
在HOSTTYPE,AspNetDevelopmentServerHost和UrlToTest是用于ASP.NET的UnitTest,不WCF的参数。只是评论这些属性,设置你的输入参数和断言和运行测试。
[TestMethod的()
公共无效AuthenticateUserTest()
{
MobileCC目标=新MobileCC(); // TODO:初始化为合适的值
字符串的AuthenticateRequest =的String.Empty; // TODO:初始化为合适的值
预计=的String.Empty串; // TODO:初始化为适当的字符串值实际;
实际= target.AuthenticateUser(的AuthenticateRequest);
Assert.AreEqual(预期,实际值);
Assert.Inconclusive(验证这种测试方法的正确性。);
}
希望这有助于。
I have created a WCF service and was trying to test one of the methods. I right clicked on the WCF service method and selected create unit test.
It created a new test project and created a unit test.
I tried to run test project but I am not sure what should be the UrlToTest
value? I have put url to the service.
[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.");
}
The HostType, AspNetDevelopmentServerHost and UrlToTest are parameters used for ASP.NET UnitTest, not WCF. Just comment those attributes, set your input parameters and asserts and run the test.
[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.");
}
Hope this helps.
这篇关于单元测试WCF方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!