private bool ValidateContext(WebHookQueueContext context) { Assert.Same(_data, context.Data); Assert.Equal(TestReceiver, context.Receiver); Assert.Equal((IEnumerable <string>)_actions, (IEnumerable <string>)context.Actions); return(true); }
public WebHookQueueContextTests() { WebHookHandlerContext context = new WebHookHandlerContext(_actions) { Id = TestId, Data = _data }; _queueContext = new WebHookQueueContext(TestReceiver, context); }
public void Serialization_Roundtrips() { // Arrange _queueContext.Data = "data"; // Act string ser = JsonConvert.SerializeObject(_queueContext, _settings); WebHookQueueContext actual = JsonConvert.DeserializeObject <WebHookQueueContext>(ser, _settings); // Assert Assert.Equal(_queueContext.Receiver, actual.Receiver); Assert.Equal(_queueContext.Actions, actual.Actions); Assert.Equal(_queueContext.Data, actual.Data); }
/// <inheritdoc /> public override async Task ExecuteAsync(string receiver, WebHookHandlerContext context) { if (receiver == null) { throw new ArgumentNullException("receiver"); } if (context == null) { throw new ArgumentNullException("context"); } try { WebHookQueueContext queueContext = new WebHookQueueContext(receiver, context); await EnqueueAsync(queueContext); } catch (Exception ex) { string msg = string.Format(CultureInfo.CurrentCulture, ReceiverResources.QueueHandler_EnqueueError, ex.Message); context.Request.GetConfiguration().DependencyResolver.GetLogger().Error(msg, ex); context.Response = context.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, msg); } }
/// <inheritdoc /> public override async Task ExecuteAsync(string receiver, WebHookHandlerContext context) { if (receiver == null) { throw new ArgumentNullException(nameof(receiver)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } try { WebHookQueueContext queueContext = new WebHookQueueContext(receiver, context); await EnqueueAsync(queueContext); } catch (Exception ex) { string msg = string.Format(CultureInfo.CurrentCulture, ReceiverResources.QueueHandler_EnqueueError, ex.Message); context.Request.GetConfiguration().DependencyResolver.GetLogger().Error(msg, ex); context.Response = context.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, msg); } }
/// <summary> /// Enqueues an incoming WebHook for processing outside its immediate HTTP request/response context. /// Any exception thrown will result in an HTTP error response being returned to the party generating /// the WebHook. /// </summary> /// <param name="context">The <see cref="WebHookQueueContext"/> for the WebHook to be enqueued.</param> public abstract Task EnqueueAsync(WebHookQueueContext context);
public WebHookQueueContextTests() { WebHookHandlerContext context = new WebHookHandlerContext(_actions) { Data = _data }; _queueContext = new WebHookQueueContext(TestReceiver, context); }
private bool ValidateContext(WebHookQueueContext context) { Assert.Same(_data, context.Data); Assert.Equal(TestReceiver, context.Receiver); Assert.Equal((IEnumerable<string>)_actions, (IEnumerable<string>)context.Actions); return true; }