public async Task Handle_WithNoEvents_ReturnsBadRequest() { EventGridEvent[] events = new EventGridEvent[] {}; Type expectedType = typeof(BadRequestResult); IActionResult actual = await _handler.Handle(events, It.IsAny <string>(), _logger); Assert.IsAssignableFrom(expectedType, actual); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger logger) { try { logger.LogInformation("Received image blob delete event."); string token = req.Query["token"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); EventGridEvent[] events = JsonConvert.DeserializeObject <EventGridEvent[]>(requestBody); return(await _handler.Handle(events, token, logger)); } catch (Exception ex) { logger.LogError(ex, ex.Message); return(new StatusCodeResult(500)); } }