public void SignWebHookRequest_HandlesNullWebHook() { WebHookWorkItem workItem = CreateWorkItem(); HttpRequestMessage request = new HttpRequestMessage(); _sender = new WebHookSenderMock(_loggerMock.Object); JObject body = _sender.CreateWebHookRequestBody(workItem); workItem.WebHook = null; // Act ArgumentException ex = Assert.Throws<ArgumentException>(() => _sender.SignWebHookRequest(workItem, request, body)); // Assert Assert.StartsWith("Invalid 'WebHookSenderMock' instance: 'WebHook' cannot be null.", ex.Message); }
public void SignWebHookRequest_HandlesNullWebHook() { WebHookWorkItem workItem = CreateWorkItem(); HttpRequestMessage request = new HttpRequestMessage(); _sender = new WebHookSenderMock(_loggerMock.Object); JObject body = _sender.CreateWebHookRequestBody(workItem); workItem.WebHook = null; // Act ArgumentException ex = Assert.Throws <ArgumentException>(() => _sender.SignWebHookRequest(workItem, request, body)); // Assert Assert.StartsWith("Invalid 'WebHookSenderMock' instance: 'WebHook' cannot be null.", ex.Message); }
public async Task SignWebHookRequest_SignsBodyCorrectly() { // Arrange WebHookWorkItem workItem = CreateWorkItem(); HttpRequestMessage request = new HttpRequestMessage(); _sender = new WebHookSenderMock(_loggerMock.Object); JObject body = _sender.CreateWebHookRequestBody(workItem); // Act _sender.SignWebHookRequest(workItem, request, body); // Assert IEnumerable<string> signature; request.Headers.TryGetValues("ms-signature", out signature); Assert.Equal(WebHookSignature, signature.Single()); string requestBody = await request.Content.ReadAsStringAsync(); Assert.Equal(SerializedWebHook, requestBody); Assert.Equal("application/json; charset=utf-8", request.Content.Headers.ContentType.ToString()); }
public async Task SignWebHookRequest_SignsBodyCorrectly() { // Arrange WebHookWorkItem workItem = CreateWorkItem(); HttpRequestMessage request = new HttpRequestMessage(); _sender = new WebHookSenderMock(_loggerMock.Object); JObject body = _sender.CreateWebHookRequestBody(workItem); // Act _sender.SignWebHookRequest(workItem, request, body); // Assert IEnumerable <string> signature; request.Headers.TryGetValues("ms-signature", out signature); Assert.Equal(WebHookSignature, signature.Single()); string requestBody = await request.Content.ReadAsStringAsync(); Assert.Equal(SerializedWebHook, requestBody); Assert.Equal("application/json; charset=utf-8", request.Content.Headers.ContentType.ToString()); }