Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }