Exemplo n.º 1
0
        public async Task CallSendApi_ByDefault_CallsHttpClientPost()
        {
            var messengerClient = new MessengerClient
                                      (_httpClient, _fbOptions);

            await messengerClient.CallSendApi(It.IsAny <string>(), It.IsAny <string>());

            _handlerMock.Protected().Verify("SendAsync", Times.Once(), ItExpr.Is <HttpRequestMessage>
                                                (req => req.Method == HttpMethod.Post), ItExpr.IsAny <CancellationToken>());
        }
Exemplo n.º 2
0
        public async Task CallSendApi_WhenRequestNotSuccessful_ThrowsApiCallException()
        {
            _response.StatusCode = HttpStatusCode.BadRequest;

            var messengerClient = new MessengerClient
                                      (_httpClient, _fbOptions);

            await Assert.ThrowsAsync <ApiCallException>
                (() => messengerClient.CallSendApi
                    (It.IsAny <string>(), It.IsAny <string>()));
        }
Exemplo n.º 3
0
        public async Task CallSendApi_ByDefault_CallsRightUri()
        {
            var messengerClient = new MessengerClient
                                      (_httpClient, _fbOptions);

            await messengerClient.CallSendApi(It.IsAny <string>(), It.IsAny <string>());

            var expectedUri = new Uri(BaseUrl + $"?access_token=");

            _handlerMock.Protected().Verify("SendAsync", Times.Once(),
                                            ItExpr.Is <HttpRequestMessage>
                                                (req => req.RequestUri == expectedUri),
                                            ItExpr.IsAny <CancellationToken>());
        }