public void ShouldReturnRestfulieProxyWithDynamicXmlContentParserUponRecievingResponseWithXmlContentTypeOnGet() { const string orderXml = "<?xml version='1.0' encoding='UTF-8'?>\r\n<resource/>"; _httpClientMock.SetupHttpClientMock(new HttpResponseMessage()); _dynamicContentParserFactoryMock.Setup(it => it.New(It.IsAny<HttpContent>())).Returns(new DynamicXmlContentParser(orderXml)); var resource = new Restfulie(It.IsAny<Uri>(), _httpClientMock.Object, _dynamicContentParserFactoryMock.Object, _httpMethodDiscovererMock.Object) .Get(); Assert.IsInstanceOfType(resource.DynamicContentParser, typeof(DynamicXmlContentParser)); }
public void ShouldSetContentStringAndContentTypeToHttpRequest() { // carlos.mendonca: no idea how to test this. const string contentType = "application/xml"; var content = new object(); _httpClientMock .Setup(it => it.Send(It.IsAny<HttpMethod>(), It.IsAny<Uri>(), It.IsAny<RequestHeaders>(), It.IsAny<HttpContent>())) .Returns(new HttpResponseMessage()); var resource = new Restfulie(It.IsAny<Uri>(), _httpClientMock.Object, _dynamicContentParserFactoryMock.Object, _httpMethodDiscovererMock.Object) .Create(content); Assert.AreEqual(content.ToString(), resource.LatestHttpResponseMessage.Request.Content.ReadAsString()); Assert.AreEqual(contentType, resource.LatestHttpResponseMessage.Request.Headers.ContentType); }
public void ShouldSetHttpResponseMessageToRestfulieProxy() { var httpResponseMessage = new HttpResponseMessage(); _httpClientMock.SetupHttpClientMock(httpResponseMessage); var resource = new Restfulie(It.IsAny<Uri>(), _httpClientMock.Object, _dynamicContentParserFactoryMock.Object, _httpMethodDiscovererMock.Object) .Get(); Assert.AreSame(httpResponseMessage, resource.LatestHttpResponseMessage); }