public void TestEnablement() { Uri localUri = new Uri("http://localhost:8000/kmlcam/xyz"); Action clientAction = () => HttpGet(localUri); using (HttpListener ws = new HttpListener(localUri, path => s2b($"~/{path}/~"))) { Assert.ThrowsAny <Exception>(clientAction); // created but not enabled; should throw exception ws.Enable(); clientAction.Invoke(); // should be available now ws.Disable(); Assert.ThrowsAny <Exception>(clientAction); // disabled, not available; should throw exception ws.Enable(); clientAction.Invoke(); // re-enabled, available again ws.Dispose(); Assert.ThrowsAny <Exception>(clientAction); // disposed, not available; should throw exception } }