Ejemplo n.º 1
0
        public void should_intercept_requests_with_interceptors()
        {
            var interceptor = FakeHttpInterceptor.SetupToAddHeader(HttpHeaders.Authorization, TokenValue);
            var callAnApi   = CallAnApi.At(Urls.Google).With(_sender).WhichRequestsInterceptedBy(interceptor);

            callAnApi.SendRequest(_request);

            Check.That(_sender.GetLastSentMessage().FirstValueOfHeader(HttpHeaders.Authorization)).IsEqualTo(TokenValue);
        }
Ejemplo n.º 2
0
        public void should_intercept_requests_in_order_of_registration()
        {
            const string sandbox           = "Sandbox";
            var          firstInterceptor  = FakeHttpInterceptor.SetupToAddHeader(sandbox, "test");
            var          secondInterceptor = FakeHttpInterceptor.SetupToAddHeader(sandbox, "test test");
            var          callAnApi         = CallAnApi.At(Urls.Google).With(_sender)
                                             .WhichRequestsInterceptedBy(firstInterceptor)
                                             .WhichRequestsInterceptedBy(secondInterceptor);

            callAnApi.SendRequest(_request);

            Check.That(_sender.GetLastSentMessage().FirstValueOfHeader(sandbox)).IsEqualTo("test");
            Check.That(_sender.GetLastSentMessage().SecondValueOfHeader(sandbox)).IsEqualTo("test test");
        }