Reputation: 5813
I have a C# library that interacts with webservers. (Specifically, it implements various means of binding local data to a remote source). All the webserver needs to do is return simple strings to simple HTTP requests. (Later, I'll add handling web sockets)
I would like to have a self-sufficient test suite for this library; so it seemed to me that a reasonable way to do this was to implement a simple C# web server (which so far seems delightfully simple). Tests could then start up a thread with the server, then run against it, and then shut down the server thread.
However, I'm running into difficulty. Is there a better way / more canonical to do this?
Note: Complex solutions are not going to be better.
Note2: Wrapping Web services in wrappers and stubbing those would defeat much of the purpose of the library in the first place.
Upvotes: 0
Views: 327
Reputation: 30725
There are other ways of creating simple web servers.
I use Node.js to create Mock web servers for testing things like C# web clients. Python is another option.
If you like to stay with C# here's another simple solution, this can be adapted: https://codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server
Upvotes: 1