Running ASP.NET Development Web Server (Cassini) as part of unit test setup?

I use WatiN, NUnit, and ReSharper to run ASP.NET unit tests inside Visual Studio. I would like (if it is not already running) to run Cassini to run my tests.

Is it possible? How should I do it?

+3
source share
3 answers

The Cassini server is WebDev.WebServer.EXE. There are several blogs that show how to start it manually. Here is one of them:

http://www.dotnetjunkies.com/WebLog/saravana/archive/2005/06/18/126143.aspx

+1
source

I just released the beta version of CassiniDev 3.5.1 / 4.0.1 with a simple testing example if you're interested.

Cassini for developers and testers: http://cassinidev.codeplex.com

Mo betta, the word.

+8
source

Here is the code:

private static void GetDevelopmentServerVPathAndPortFromProjectFile( string csprojFileName, out string developmentServerVPath, out int developmentServerPort) { XPathDocument doc = new XPathDocument(csprojFileName); XPathNavigator navigator = doc.CreateNavigator(); XmlNamespaceManager manager = new XmlNamespaceManager(navigator.NameTable); manager.AddNamespace("msbuild", "http://schemas.microsoft.com/developer/msbuild/2003"); const string xpath = "/msbuild:Project/msbuild:ProjectExtensions/" + "msbuild:VisualStudio/msbuild:FlavorProperties/" + "msbuild:WebProjectProperties"; XPathNavigator webProjectPropertiesNode = navigator.SelectSingleNode(xpath, manager); XPathNavigator developmentServerPortNode = webProjectPropertiesNode.SelectSingleNode("msbuild:DevelopmentServerPort", manager); XPathNavigator developmentServerVPathNode = webProjectPropertiesNode.SelectSingleNode("msbuild:DevelopmentServerVPath", manager); developmentServerPort = developmentServerPortNode.ValueAsInt; developmentServerVPath = developmentServerVPathNode.Value; } private static string GetCommonProgramFilesPath() { string commonProgramFiles = Environment.GetEnvironmentVariable("CommonProgramFiles(x86)"); if (string.IsNullOrEmpty(commonProgramFiles)) { commonProgramFiles = Environment.GetEnvironmentVariable("CommonProgramFiles"); } if (string.IsNullOrEmpty(commonProgramFiles)) { commonProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles); } return commonProgramFiles; } private static Process PrepareCassiniProcess(int developmentServerPort, string projectPhysicalPath, string developmentServerVPath) { string commonProgramFiles = GetCommonProgramFilesPath(); string cassiniPath = Path.Combine(commonProgramFiles, @"Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe"); string cassiniArgs = string.Format( CultureInfo.InvariantCulture, "/port:{0} /nodirlist /path:\"{1}\" /vpath:\"{2}\"", developmentServerPort, projectPhysicalPath, developmentServerVPath); Process cassiniProcess = new Process(); cassiniProcess.StartInfo.FileName = cassiniPath; cassiniProcess.StartInfo.Arguments = cassiniArgs; return cassiniProcess; } 

To use it, you need to open the path to the CSPROJ file of the web project being tested. I will leave this as an exercise for the reader (currently I got hard coding).

+2
source

All Articles