# 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

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
Map(...) | 3 | 4 | 100 | 80
.ctor() | 1 | 0 | 100 | 100

# File(s)

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

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System.Linq;`
|  | `2` |  | `using System.Net;`
|  | `3` |  | `using System.Text;`
|  | `4` |  | ``
|  | `5` |  | `namespace WireMock`
|  | `6` |  | `{`
|  | `7` |  | `/// <summary>`
|  | `8` |  | `/// The http listener response mapper.`
|  | `9` |  | `/// </summary>`
|  | `10` |  | `public class HttpListenerResponseMapper`
|  | `11` |  | `{`
| 22 | `12` |  | `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)`
| 17 | `22` |  | `{`
| 17 | `23` |  | `listenerResponse.StatusCode = responseMessage.StatusCode;`
|  | `24` |  | ``
| 19 | `25` |  | `responseMessage.Headers.ToList().ForEach(pair => listenerResponse.AddHeader(pair.Key, pair.Value));`
|  | `26` |  | ``
| 17 | `27` |  | `if (responseMessage.Body == null)`
| 4 | `28` |  | `return;`
|  | `29` |  | ``
| 13 | `30` |  | `var encoding = responseMessage.BodyEncoding ?? _utf8NoBom;`
| 13 | `31` |  | `byte[] buffer = encoding.GetBytes(responseMessage.Body);`
|  | `32` |  | ``
| 13 | `33` |  | `listenerResponse.ContentEncoding = encoding;`
| 13 | `34` |  | `listenerResponse.ContentLength64 = buffer.Length;`
| 13 | `35` |  | `listenerResponse.OutputStream.Write(buffer, 0, buffer.Length);`
| 13 | `36` |  | `listenerResponse.OutputStream.Flush();`
| 17 | `37` |  | `}`
|  | `38` |  | `}`
|  | `39` |  | `}`

# Methods/Properties

.ctor()
Map(WireMock.ResponseMessage,System.Net.HttpListenerResponse)