Summary

Class:WireMock.HttpListenerResponseMapper
Assembly:WireMock.Net
File(s):C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\HttpListenerResponseMapper.cs
Covered lines:13
Uncovered lines:0
Coverable lines:13
Total lines:39
Line coverage:100%
Branch coverage:75%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
Map(...)3410080
.ctor()10100100

File(s)

C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\HttpListenerResponseMapper.cs

#LineLine coverage
 1using System.Linq;
 2using System.Net;
 3using System.Text;
 4
 5namespace WireMock
 6{
 7    /// <summary>
 8    /// The http listener response mapper.
 9    /// </summary>
 10    public class HttpListenerResponseMapper
 11    {
 2212        private readonly Encoding _utf8NoBom = new UTF8Encoding(false);
 13
 14        /// <summary>
 15        /// The map.
 16        /// </summary>
 17        /// <param name="responseMessage">
 18        /// The response.
 19        /// </param>
 20        /// <param name="listenerResponse">The listenerResponse.</param>
 21        public void Map(ResponseMessage responseMessage, HttpListenerResponse listenerResponse)
 1722        {
 1723            listenerResponse.StatusCode = responseMessage.StatusCode;
 24
 1925            responseMessage.Headers.ToList().ForEach(pair => listenerResponse.AddHeader(pair.Key, pair.Value));
 26
 1727             if (responseMessage.Body == null)
 428                return;
 29
 1330             var encoding = responseMessage.BodyEncoding ?? _utf8NoBom;
 1331            byte[] buffer = encoding.GetBytes(responseMessage.Body);
 32
 1333            listenerResponse.ContentEncoding = encoding;
 1334            listenerResponse.ContentLength64 = buffer.Length;
 1335            listenerResponse.OutputStream.Write(buffer, 0, buffer.Length);
 1336            listenerResponse.OutputStream.Flush();
 1737        }
 38    }
 39}