void CustomPrefixesShouldThrow() { var subject = new PatchMapping() { Source = "File1.bin", Destination = "EFI\\Microsoft\\Boot", TargetPartition = TargetPartition.Boot, Condition = new Always(), }; var serializer = new ConfigurationContainer().EnableImplicitTypingFromPublicNested <Issue231Tests>() .Extend(Extension.Default) .Create(); using (var xmlTextWriter = new Writer()) { Action action = () => serializer.Serialize(xmlTextWriter, subject); action.ShouldThrow <InvalidOperationException>().WithMessage("Nope."); } }
public static void RunWith(HttpListenerContext context) { string path = context.Request.Url.PathAndQuery; string httpMethod = context.Request.HttpMethod; try { HttpMethod method = (HttpMethod)Enum.Parse(typeof(HttpMethod), httpMethod, true); switch (method) { case HttpMethod.GET: GetResponse(GetMapping.FindPath(path, method, context), context); break; case HttpMethod.POST: GetResponse(PostMapping.FindPath(path, method, context), context); break; case HttpMethod.DELETE: GetResponse(DeleteMapping.FindPath(path, method, context), context); break; case HttpMethod.PUT: GetResponse(PutMapping.FindPath(path, method, context), context); break; case HttpMethod.PATCH: GetResponse(PatchMapping.FindPath(path, method, context), context); break; case HttpMethod.OPTIONS: var requestedMethod = Enum.Parse <HttpMethod>(context.Request.Headers.Get("Access-Control-Request-Method")); var requestedHeaders = context.Request.Headers.Get("Access-Control-Request-Headers"); var response = AbstractMapping.HandleOptionsRequest(path, requestedMethod, requestedHeaders); SendResponse(response, context); break; default: throw new ServerRequestMethodNotSupportedException($"{httpMethod} is not supported", context); } } catch (ServerRequestMethodNotSupportedException ex) { ExceptionHandler.HandleException(ex, context); } catch (ServerEndpointNotValidException ex) { ExceptionHandler.HandleException(ex, context); } catch (Exception ex) { try { throw new InternalServerErrorException(ex.Message, context, ex); } catch (InternalServerErrorException e) { ExceptionHandler.HandleException(e, context); } } }