public void Stub(ApiExpectation expectation) { _expectations.Add(expectation); }
private void SendResponse(HttpListenerContext context, string body, ApiExpectation expectation) { var response = context.Response; response.StatusCode = expectation.Status ?? 200; response.ContentLength64 = (expectation.Response ?? body).Length; using (var sw = new StreamWriter(response.OutputStream)) { sw.Write(expectation.Response ?? body); } response.Close(); }