Ejemplo n.º 1
0
 public Task ChallengeAsync(
     HttpAuthenticationChallengeContext context,
     CancellationToken cancellationToken
     )
 {
     ExceptionTestsUtility.CheckForThrow(_throwAt, "AuthenticationChallenge");
     return(Task.FromResult <object>(null));
 }
Ejemplo n.º 2
0
        public override ContentNegotiationResult Negotiate(
            Type type,
            HttpRequestMessage request,
            IEnumerable <MediaTypeFormatter> formatters
            )
        {
            ExceptionTestsUtility.CheckForThrow(_throwAt, "ContentNegotiatorNegotiate");

            return(base.Negotiate(type, request, formatters));
        }
Ejemplo n.º 3
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            ExceptionTestsUtility.CheckForThrow(_throwAt, "RequestMessageHandler");

            HttpResponseMessage response = await base.SendAsync(request, cancellationToken);

            ExceptionTestsUtility.CheckForThrow(_throwAt, "ResponseMessageHandler");

            return(response);
        }
Ejemplo n.º 4
0
        public override Task <object> ReadFromStreamAsync(
            Type type,
            Stream readStream,
            HttpContent content,
            IFormatterLogger formatterLogger
            )
        {
            ExceptionTestsUtility.CheckForThrow(_throwAt, "MediaTypeFormatterReadFromStreamAsync");

            return(base.ReadFromStreamAsync(type, readStream, content, formatterLogger));
        }
Ejemplo n.º 5
0
        public override Task WriteToStreamAsync(
            Type type,
            object value,
            Stream writeStream,
            HttpContent content,
            TransportContext transportContext
            )
        {
            ExceptionTestsUtility.CheckForThrow(_throwAt, "MediaTypeFormatterWriteToStreamAsync");

            return(base.WriteToStreamAsync(type, value, writeStream, content, transportContext));
        }
Ejemplo n.º 6
0
        public string ReturnString([FromBody] string throwAt)
        {
            string message = "Hello World!";

            // check if the test wants to throw from here
            ExceptionTestsUtility.CheckForThrow(throwAt, "ActionMethod");

            // NOTE: this indicates that we want to throw from here & after this gets intercepted
            // by the ExceptionFilter, we want to throw from there too
            ExceptionTestsUtility.CheckForThrow(throwAt, "ActionMethodAndExceptionFilter");

            return(message);
        }
Ejemplo n.º 7
0
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            ExceptionTestsUtility.CheckForThrow(_throwAt, "RequestMessageHandler");

            return(base.SendAsync(request, cancellationToken).ContinueWith <HttpResponseMessage>((tsk) =>
            {
                ExceptionTestsUtility.CheckForThrow(_throwAt, "ResponseMessageHandler");

                HttpResponseMessage response = tsk.Result;

                return response;
            }));
        }
Ejemplo n.º 8
0
 public override void OnException(HttpActionExecutedContext context)
 {
     ExceptionTestsUtility.CheckForThrow(_throwAt, "ActionMethodAndExceptionFilter");
 }
Ejemplo n.º 9
0
 public override void OnActionExecuted(HttpActionExecutedContext context)
 {
     ExceptionTestsUtility.CheckForThrow(_throwAt, "AfterActionExecuted");
 }
Ejemplo n.º 10
0
 public override void OnActionExecuting(HttpActionContext context)
 {
     ExceptionTestsUtility.CheckForThrow(_throwAt, "BeforeActionExecuted");
 }
Ejemplo n.º 11
0
 public override void OnAuthorization(HttpActionContext context)
 {
     ExceptionTestsUtility.CheckForThrow(_throwAt, "RequestAuthorization");
 }