public void NoSyncExecution()
        {
            NoOpExecutionInterceptor   interceptor1 = new NoOpExecutionInterceptor();
            NoOpRequestSyncInterceptor interceptor2 = new NoOpRequestSyncInterceptor();

            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                                                                      new IClientHttpRequestInterceptor[] { interceptor1, interceptor2 });

            IClientHttpRequest  request  = requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET);
            IClientHttpResponse response = request.Execute();

            Assert.IsFalse(interceptor2.invoked);
            Assert.IsFalse(requestMock.executed);
        }
        public void NoAsyncExecution()
        {
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            Exception        exception   = null;

            NoOpExecutionInterceptor    interceptor1 = new NoOpExecutionInterceptor();
            NoOpRequestAsyncInterceptor interceptor2 = new NoOpRequestAsyncInterceptor();

            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                                                                      new IClientHttpRequestInterceptor[] { interceptor1, interceptor2 });

            IClientHttpRequest request = requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET);

            request.ExecuteAsync(null, delegate(ClientHttpRequestCompletedEventArgs args)
            {
                try
                {
                    Assert.Fail("No Execution");
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
                finally
                {
                    manualEvent.Set();
                }
            });

            //manualEvent.WaitOne();
            if (exception != null)
            {
                throw exception;
            }

            Assert.IsFalse(interceptor2.invoked);
            Assert.IsFalse(requestMock.executed);
        }
        public void NoAsyncExecution()
        {
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            Exception exception = null;

            NoOpExecutionInterceptor interceptor1 = new NoOpExecutionInterceptor();
            NoOpRequestAsyncInterceptor interceptor2 = new NoOpRequestAsyncInterceptor();
            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                new IClientHttpRequestInterceptor[] { interceptor1, interceptor2 });

            IClientHttpRequest request = requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET);
            request.ExecuteAsync(null, delegate(ClientHttpRequestCompletedEventArgs args)
            {
                try
                {
                    Assert.Fail("No Execution");
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
                finally
                {
                    manualEvent.Set();
                }
            });

            //manualEvent.WaitOne();
            if (exception != null)
            {
                throw exception;
            }

            Assert.IsFalse(interceptor2.invoked);
            Assert.IsFalse(requestMock.executed);
        }
        public void NoSyncExecution()
        {
            NoOpExecutionInterceptor interceptor1 = new NoOpExecutionInterceptor();
            NoOpRequestSyncInterceptor interceptor2 = new NoOpRequestSyncInterceptor();
            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                new IClientHttpRequestInterceptor[] { interceptor1, interceptor2 });

            IClientHttpRequest request = requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET);
            IClientHttpResponse response = request.Execute();

            Assert.IsFalse(interceptor2.invoked);
            Assert.IsFalse(requestMock.executed);
        }