ExecuteWebHookAsync() 공개 메소드

public ExecuteWebHookAsync ( string id, System.Web.Http.Controllers.HttpRequestContext context, HttpRequestMessage request, IEnumerable actions, object data ) : Task
id string
context System.Web.Http.Controllers.HttpRequestContext
request System.Net.Http.HttpRequestMessage
actions IEnumerable
data object
리턴 Task
예제 #1
0
        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);
        }
예제 #2
0
        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);
        }