コード例 #1
0
        public void Not_support_converting_to_request_by_reference()
        {
            // Arrange
            var selfConverter      = new SelfMessageConverter();
            var stubRequestContext = new RequestContext(RequestMethod.GET, "", new Dictionary <string, string>(), new byte[] { 1 });

            // Act
            var action = new Action(() => selfConverter.ConvertToRequest(null, ref stubRequestContext));

            // Assert
            Assert.Throws <NotSupportedException>(action);
        }
コード例 #2
0
        public void Convert_RequestContext_to_request_without_changes()
        {
            // Arrange
            var selfConverter  = new SelfMessageConverter();
            var requestContext = new RequestContext(RequestMethod.GET, "/test", new Dictionary <string, string> {
                { "test", "test" }
            }, new byte[] { 1 });

            // Act
            var request = selfConverter.ConvertToRequest(requestContext);

            // Assert
            Assert.Equal(requestContext, request);
            Assert.Equal(requestContext.Method, request.Method);
            Assert.Equal(requestContext.Path, request.Path);
            Assert.Equal(requestContext.RawContent, request.RawContent);
            var headersFromContext = requestContext.Headers.ToDictionary(context => context.Key, context => context.Value);
            var headersFromRequest = request.Headers.ToDictionary(context => context.Key, context => context.Value);

            Assert.Equal(headersFromContext, headersFromRequest);
        }