I have created the default webservice asmx hello world :
namespace WebServiceHello
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
I then generate a MS Test with Visual Studio and set expected value:
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\temp\\WebServiceHello\\WebServiceHello", "/")]
[UrlToTest("http://localhost:7352/")]
public void HelloWorldTest()
{
Service1 target = new Service1(); // TODO: Initialize to an appropriate value
string expected = "Hello World"; // TODO: Initialize to an appropriate value
string actual;
actual = target.HelloWorld();
Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
}
but I got this error message:
The Web request 'http://localhost:7352/' completed successfully without running the test. This can occur when configuring the Web application for testing fails (an ASP.NET server error occurs when processing the request), or when no ASP.NET page is executed (the URL may point to an HTML page, a Web service, or a directory listing). Running tests in ASP.NET requires the URL to resolve to an ASP.NET page and for the page to execute properly up to the Load event. The response from the request is stored in the file 'WebRequestResponse_HelloWorldTest.html' with the test results; typically this file can be opened with a Web browser to view its contents.
and as Test Files : WebRequestResponse_HelloWorldTest.html which contains
<html>
<head>
<title>Directory Listing -- /</title>
<style>
body {font-family:"Verdana";font-weight:normal;font-size: 8pt;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: 8pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
</style>
</head>
<body bgcolor="white">
<h2> <i>Directory Listing -- /</i> </h2></span>
<hr width=100% size=1 color=silver>
<PRE>
Saturday, September 25, 2010 06:39 PM <dir> <A href="App_Data/">App_Data</A>
Saturday, September 25, 2010 06:40 PM <dir> <A href="bin/">bin</A>
Saturday, September 25, 2010 06:39 PM <dir> <A href="obj/">obj</A>
Saturday, September 25, 2010 06:39 PM <dir> <A href="Properties/">Properties</A>
Saturday, September 25, 2010 06:39 PM 97 <A href="Service1.asmx">Service1.asmx</A>
Saturday, September 25, 2010 06:39 PM 572 <A href="Service1.asmx.cs">Service1.asmx.cs</A>
Saturday, September 25, 2010 06:44 PM 3,551 <A href="Web.config">Web.config</A>
Saturday, September 25, 2010 06:39 PM 968 <A href="web.config.backup">web.config.backup</A>
Saturday, September 25, 2010 06:39 PM 1,285 <A href="Web.Debug.config">Web.Debug.config</A>
Saturday, September 25, 2010 06:39 PM 1,346 <A href="Web.Release.config">Web.Release.config</A>
Saturday, September 25, 2010 06:40 PM 3,805 <A href="WebServiceHello.csproj">WebServiceHello.csproj</A>
Saturday, September 25, 2010 06:40 PM 1,086 <A href="WebServiceHello.csproj.user">WebServiceHello.csproj.user</A>
</PRE>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> ASP.NET Development Server 10.0.0.0
</font>
</body>
</html>
The test shouldn't fail since actual is expected so what I did setup wrongly ?