hibri / HttpMock

A library for creating Http servers on the fly in tests and stubbing responses
MIT License
128 stars 44 forks source link

HttpServer.Dispose unexpectedly disposes all http servers #47

Closed neoistheone123 closed 8 years ago

neoistheone123 commented 8 years ago

I noticed that calling dispose on one server, disposes the other servers. I verified with IsAvailable that the other servers were shutdown.

public void Dispose() { if (_scheduler != null) { _scheduler.Stop(); _scheduler.Dispose(); } if (_disposableServer != null) { _disposableServer.Dispose(); } }

_disposableServer = KayakServer.Factory .CreateHttp(_requestProcessor, _scheduler) .Listen(ipEndPoint);

Seems to be due to same IP?

hibri commented 8 years ago

There is only one server for each IP/Port combination.

neoistheone123 commented 8 years ago

I have used different ports for each IHttpServer object. IP is localhost.

hibri commented 8 years ago

Could you please send a test suite that reproduces the issue ?

neoistheone123 commented 8 years ago

IHttpServer serverA=null, serverB=null, serverC=null;

try{ serverA = createA(); serverB = createB(); serverC= createC(); action.Invoke(); } finally{ serverA.Dispose(); serverB.Dispose() serverC.Dispose(); }

hibri commented 8 years ago

I'll need the full code :) What is inside createA() ...

neoistheone123 commented 8 years ago

I'm not allowed to release the code. I've written some tests around it. I've been able to narrow it down to FactoryGirl. Thanks for your input!