Thursday, October 02, 2008

Webserver for NUnit tests

What's the best way of setting up a simple HTTP file server to be used purely for NUnit tests. What I'm looking for is a way to set up a server so that I can host some files in. My NUnit tests will then initiate HTTP requests to 'download' those files.

Ideally whatever method I choose won't require me to write temporary files to disk. Currently what I do is host a HttpListener and manually fulfill the requested data by creating an in-memory byte[] and writing that into the response. I'd like to do something like:

webServer.Add("path/where/file/is", CreateFakeByteArray());

Then the server will fulfill requests from this faked byte[].

The reason for this setup is that I need a better way to test my implementation of WebSeeding in MonoTorrent without having to code up my own buggy file server ;)

2 comments:

Anonymous said...

Coincidentally I've just been creating such a thing, as a project to see if automated tests could be made for the MWF WebBrowser control. I based on some design work I'd done in a previous web client testing project.

You're welcome to see/use it. It's not _the_ most tested bit of software I've every written, partly as we're nearing that test paradox of writing tests for the tests of the tests of the tests. At the moment it doesn't support sending binary content but that should be simple to add if you give me a day or three.

Drop me a line if you're interested: email yahoo.co.uk userid andyhume32.

Andy

Alan said...

Hey,

Just a FYI, I was told about Mono.WebServer, which is pretty much exactly what i need. This is used by XSP already.

Hit Counter