Esempio n. 1
0
        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");
                }
        }
Esempio n. 2
0
        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);
                }
        }
Esempio n. 3
0
 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);
     }
 }