public void Ctor_ToBeConstructedCorrectly()
 {
     const string responseBody = "response body";
     var response = new HttpClientResponse(HttpStatusCode.OK, responseBody);
     Assert.AreEqual(HttpStatusCode.OK,response.StatusCode);
     Assert.AreEqual(responseBody, response.ResponseBody);
 }
Beispiel #2
0
        public void Publish_ShouldReturnTrue_WhenHubPublishCallReturnNoContent204Response()
        {
            const string actualRequestBody = "Actual Request Body";
            var httpClientResponse = new HttpClientResponse(HttpStatusCode.NoContent, actualRequestBody);

            _mockHttpClient.Setup(x => x.Post(It.IsAny<string>())).Returns(httpClientResponse);

            var publisherClient = new PublisherClient(_mockHttpClient.Object);
            var publishResult = publisherClient.Publish(FeedUrl);

            Assert.IsTrue(publishResult);
        }
Beispiel #3
0
        public void Publish_ShouldCreateCorrectRequestData()
        {
            const string actualRequestBody = "Actual Request Body";
            string actualRequestData = null;
            var httpClientResponse = new HttpClientResponse(HttpStatusCode.NoContent, actualRequestBody);

            _mockHttpClient.Setup(x => x.Post(It.IsAny<string>()))
                .Callback(delegate(string paramRequestData) { actualRequestData = paramRequestData; })
                .Returns(httpClientResponse);

            var publisherClient = new PublisherClient(_mockHttpClient.Object);
            //var publisherClient = new PublisherClient("http://localhost.:8080/publish");
            var publishResult = publisherClient.Publish(FeedUrl);

            Assert.IsTrue(publishResult);
            Assert.AreEqual(_expectedRequestData,actualRequestData);
        }