public void ChangeResponse()
        {
            ChangeResponseInterceptor interceptor = new ChangeResponseInterceptor();

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

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

            Assert.AreNotSame(this.responseMock, response);
        }
        public void ChangeResponseAsync()
        {
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            Exception        exception   = null;
            Object           state       = new Object();

            ChangeResponseInterceptor interceptor = new ChangeResponseInterceptor();

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

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

            request.ExecuteAsync(state, delegate(ClientHttpRequestCompletedEventArgs args)
            {
                try
                {
                    Assert.IsNull(args.Error, "Invalid response");
                    Assert.IsFalse(args.Cancelled, "Invalid response");
                    Assert.AreNotSame(this.responseMock, args.Response, "Invalid response");
                    Assert.AreEqual(state, args.UserState);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
                finally
                {
                    manualEvent.Set();
                }
            });

            manualEvent.WaitOne();
            if (exception != null)
            {
                throw exception;
            }
        }
        public void ChangeResponseAsync()
        {
            ManualResetEvent manualEvent = new ManualResetEvent(false);
            Exception exception = null;
            Object state = new Object();

            ChangeResponseInterceptor interceptor = new ChangeResponseInterceptor();
            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                new IClientHttpRequestInterceptor[] { interceptor });

            IClientHttpRequest request = requestFactory.CreateRequest(new Uri("http://example.com"), HttpMethod.GET);
            request.ExecuteAsync(state, delegate(ClientHttpRequestCompletedEventArgs args)
            {
                try
                {
                    Assert.IsNull(args.Error, "Invalid response");
                    Assert.IsFalse(args.Cancelled, "Invalid response");
                    Assert.AreNotSame(this.responseMock, args.Response, "Invalid response");
                    Assert.AreEqual(state, args.UserState);
                }
                catch (Exception ex)
                {
                    exception = ex;
                }
                finally
                {
                    manualEvent.Set();
                }
            });

            manualEvent.WaitOne();
            if (exception != null)
            {
                throw exception;
            }
        }
        public void ChangeResponse()
        {
            ChangeResponseInterceptor interceptor = new ChangeResponseInterceptor();
            requestFactory = new InterceptingClientHttpRequestFactory(requestFactoryMock,
                new IClientHttpRequestInterceptor[] { interceptor });

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

            Assert.AreNotSame(this.responseMock, response);
        }