[Mono-dev] framework for system.web tests

Andrew Skiba andrews at mainsoft.com
Thu May 4 05:31:01 EDT 2006


Hello.

I created a simple framework that might help in creating unit tests for
system.web, and want to contribute it. When we tryed to write test for
SiteMapPath.Render, we saw that it needs many things from HttpContext.
Now it's possible to create a method that will run in a web context,
looking like:

	public static void TestMapSitePath (HttpContext context, object
param)
	{
		Control c = new System.Web.UI.WebControls.MapSitePath
();
		c.Page = new Page ();
		using (HtmlTextWriter htw = new HtmlTextWriter
(context.Response.Output)) {
			c.RenderControl (htw);
		}
	}

and to call it like this:

	string res = NunitWeb.Helper.Run (TestMapSitePath, null));

the result can be used in a regular nunit assert:

	Assert.AreEqual (@"<span><a href=""#_SkipLink""><img alt=""Skip
Navigation Links"" height=""0"" width=""0""
src=""/NunitWeb/WebResource.axd?d=HkJ8fQo6w7kxQaySxHq4Lg2&amp;t=63279744
5633148088"" style=""border-width:0px;"" /></a><a
id=""_SkipLink""></a></span>", res);

This framework works good on dotnet, but unfortunately, on mono there is
bug with web.config. I reproduced it, and reported here:
http://bugzilla.ximian.com/show_bug.cgi?id=78256. When it's fixed I hope
we will be able to use this framework on mono, too.

Is it OK to commmit this framework to sys.web/Tests ?

Regards,
Andrew.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NunitWeb.csproj
Type: application/octet-stream
Size: 3769 bytes
Desc: NunitWeb.csproj
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060504/eb87485d/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Web.config
Type: application/octet-stream
Size: 338 bytes
Desc: Web.config
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060504/eb87485d/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Helper.cs
Type: application/octet-stream
Size: 2309 bytes
Desc: Helper.cs
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060504/eb87485d/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyHandler.cs
Type: application/octet-stream
Size: 621 bytes
Desc: MyHandler.cs
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060504/eb87485d/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyHost.cs
Type: application/octet-stream
Size: 1667 bytes
Desc: MyHost.cs
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060504/eb87485d/attachment-0004.obj 


More information about the Mono-devel-list mailing list