コード例 #1
1
        public void Soap11ClientIssuesAValidRequest()
        {
            var mockMessageHandler = new MockHttpMessageHandler();
            mockMessageHandler
                .Expect(HttpMethod.Post, FakeEndpoint)
                .With(req => req.Content.Headers.ContentType.MediaType == Soap11MediaType)
                .With(req => req.Content.Headers.ContentType.CharSet == SoapCharSet)
                .Respond(HttpStatusCode.OK);

            Task<HttpResponseMessage> result;
            using (var sut = new SoapClient(() => new HttpClient(mockMessageHandler)))
            {
                result = sut.PostAsync(FakeEndpoint, _fakeBody);
            }
            result.ShouldBeType(typeof(Task<HttpResponseMessage>));
            mockMessageHandler.VerifyNoOutstandingExpectation();
        }
コード例 #2
0
        public void Soap11ClientIncludesSoapActionParameter()
        {
            var mockMessageHandler = new MockHttpMessageHandler();
            mockMessageHandler
                .Expect(HttpMethod.Post, FakeEndpoint)
                .With(req => req.Content.Headers.Single(h => h.Key == "SOAPAction").Value.Single() == FakeAction)
                .Respond(HttpStatusCode.OK);

            Task<HttpResponseMessage> result;
            using (var sut = new SoapClient(() => new HttpClient(mockMessageHandler)))
            {
                result = sut.PostAsync(FakeEndpoint, _fakeBody, action: FakeAction);
            }
            result.ShouldBeType(typeof(Task<HttpResponseMessage>));
            mockMessageHandler.VerifyNoOutstandingExpectation();
        }