예제 #1
0
        public void AddContent_WithHttpWebRequestAdapterAndHttpRequest()
        {
            // Arrange
            Mock <IHttpWebRequestAdapter> mockHttpWebRequest = mocks.Create <IHttpWebRequestAdapter>();

            HttpRequest request = new HttpRequest()
            {
                Content         = "content",
                ContentEncoding = Encoding.UTF8,
                ContentType     = "application/xml"
            };

            Stream stream = new MemoryStream();

            mockHttpWebRequest.Setup(wr => wr.GetRequestStream()).Returns(stream);
            mockHttpWebRequest.SetupSet(wr => wr.ContentLength = request.ContentLength);
            mockHttpWebRequest.SetupSet(wr => wr.ContentType   = request.ContentType);

            // Act
            helper.AddContent(mockHttpWebRequest.Object, request);

            // Assert

            // Expectations have been met.
        }
예제 #2
0
        public void AddContent_WithHttpWebRequestAdapterAndHttpRequest()
        {
            // Arrange
            var httpWebRequest = new Mock <IHttpWebRequestAdapter>();

            var request = new HttpRequest
            {
                Content         = "content",
                ContentEncoding = Encoding.UTF8,
                ContentType     = "application/xml"
            };

            Stream stream = new MemoryStream();

            httpWebRequest.Setup(wr => wr.GetRequestStream())
            .Returns(stream);

            // Act
            _helper.AddContent(httpWebRequest.Object, request);

            // Assert
            httpWebRequest.VerifySet(wr => wr.ContentLength = request.ContentLength);
            httpWebRequest.VerifySet(wr => wr.ContentType   = request.ContentType);
        }