Summary

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

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor()10100100
MapAsync()8410080

File(s)

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

#LineLine coverage
 1using System.IO;
 2using System.Linq;
 3using System.Text;
 4using System.Threading.Tasks;
 5#if NET45
 6using Microsoft.Owin;
 7#else
 8using Microsoft.AspNetCore.Http;
 9#endif
 10
 11namespace WireMock.Owin
 12{
 13    /// <summary>
 14    /// OwinResponseMapper
 15    /// </summary>
 16    public class OwinResponseMapper
 17    {
 1618        private readonly Encoding _utf8NoBom = new UTF8Encoding(false);
 19
 20        /// <summary>
 21        /// MapAsync ResponseMessage to OwinResponse
 22        /// </summary>
 23        /// <param name="responseMessage"></param>
 24        /// <param name="response"></param>
 25        public async Task MapAsync(ResponseMessage responseMessage
 26#if NET45
 27            , IOwinResponse response
 28#else
 29            , HttpResponse response
 30#endif
 31            )
 1332        {
 1333            response.StatusCode = responseMessage.StatusCode;
 34
 1435            responseMessage.Headers.ToList().ForEach(pair => response.Headers.Append(pair.Key, pair.Value));
 36
 1337             if (responseMessage.Body == null)
 238                return;
 39
 1140            Encoding encoding = responseMessage.BodyEncoding ?? _utf8NoBom;
 1141             using (var writer = new StreamWriter(response.Body, encoding))
 1142            {
 1143                await writer.WriteAsync(responseMessage.Body);
 1144            }
 1345        }
 46    }
 47}

Methods/Properties

.ctor()
MapAsync()