public ExecuteWebHookAsync ( string id, System.Web.Http.Controllers.HttpRequestContext context, |
||
id | string | |
context | System.Web.Http.Controllers.HttpRequestContext | |
request | ||
actions | IEnumerable |
|
data | object | |
Результат | Task |
public async Task ExecuteWebHookAsync_FindsMatchingHandlers() { // Arrange List<TestHandler> handlers = new List<TestHandler>() { new TestHandler { Order = 10, Receiver = "other" }, new TestHandler { Order = 20, Receiver = "MockReceiver" }, new TestHandler { Order = 30, Receiver = "MOCKRECEIVER" }, new TestHandler { Order = 40, Receiver = null }, new TestHandler { Order = 50, Receiver = "something" }, }; _resolverMock.Setup(r => r.GetServices(typeof(IWebHookHandler))) .Returns(handlers) .Verifiable(); WebHookReceiverMock receiver = new WebHookReceiverMock(); object data = new object(); // Act HttpResponseMessage actual = await receiver.ExecuteWebHookAsync(WebHookReceiverMock.ReceiverName, _context, _request, new[] { "action" }, data); // Assert _resolverMock.Verify(); Assert.Equal("OK", actual.ReasonPhrase); Assert.False(handlers[0].IsCalled); Assert.True(handlers[1].IsCalled); Assert.True(handlers[2].IsCalled); Assert.True(handlers[3].IsCalled); Assert.False(handlers[4].IsCalled); }
public async Task ExecuteWebHookAsync_StopsOnFirstResponse() { // Arrange List<TestHandler> handlers = new List<TestHandler>() { new TestHandler { Order = 10, }, new TestHandler { Order = 20, }, new TestHandler { Order = 30, SetResponse = true }, new TestHandler { Order = 40, }, }; _resolverMock.Setup(r => r.GetServices(typeof(IWebHookHandler))) .Returns(handlers) .Verifiable(); WebHookReceiverMock receiver = new WebHookReceiverMock(); object data = new object(); // Act HttpResponseMessage actual = await receiver.ExecuteWebHookAsync(WebHookReceiverMock.ReceiverName, _context, _request, new[] { "action" }, data); // Assert _resolverMock.Verify(); Assert.Equal("Order: 30", actual.ReasonPhrase); Assert.True(handlers[0].IsCalled); Assert.True(handlers[1].IsCalled); Assert.True(handlers[2].IsCalled); Assert.False(handlers[3].IsCalled); }