static void OnRequestReceived() { var autoResetEvent = new AutoResetEvent(false); using (var fakeService = new FakeService()) using (var httpClient = HttpClient(fakeService.Start())) { fakeService.AddResponse("/foo", Method.GET, Response.WithStatusCode(200)); fakeService.OnRequestReceived(request => { if (request.Path == "/foo") { autoResetEvent.Set(); } }); httpClient.GetAsync("/foo").Result.EnsureSuccessStatusCode(); Expect.equal(autoResetEvent.WaitOne(1000), true, "AutoResetEvent is triggered"); } }
public void Request_received_event() { var autoResetEvent = new AutoResetEvent(false); using (var fakeService = new FakeService()) using (var httpClient = HttpClient(fakeService.Start())) { fakeService.AddResponse("/foo", Method.GET, Response.WithStatusCode(200)); fakeService.OnRequestReceived(request => { if (request.Path == "/foo") { autoResetEvent.Set(); } }); httpClient.GetAsync("/foo").Result.EnsureSuccessStatusCode(); Assert.That(autoResetEvent.WaitOne(1000), Is.True); } }