Summary

Class:WireMock.ResponseMessage
Assembly:WireMock.Net
File(s):C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\ResponseMessage.cs
Covered lines:20
Uncovered lines:0
Coverable lines:20
Total lines:91
Line coverage:100%
Branch coverage:50%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
AddHeader(...)10100100
AddHeader(...)3210066.67
.ctor()10100100

File(s)

C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\ResponseMessage.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using WireMock.Util;
 6using WireMock.Validation;
 7
 8namespace WireMock
 9{
 10    /// <summary>
 11    /// The response.
 12    /// </summary>
 13    public class ResponseMessage
 14    {
 15        /// <summary>
 16        /// Gets the headers.
 17        /// </summary>
 36218        public IDictionary<string, WireMockList<string>> Headers { get; set; } = new ConcurrentDictionary<string, WireMo
 19
 20        /// <summary>
 21        /// Gets or sets the status code.
 22        /// </summary>
 27023        public int StatusCode { get; set; } = 200;
 24
 25        /// <summary>
 26        /// Gets or sets the body.
 27        /// </summary>
 728        public string BodyOriginal { get; set; }
 29
 30        /// <summary>
 31        /// Gets or sets the body destination (SameAsSource, String or Bytes).
 32        /// </summary>
 3933        public string BodyDestination { get; set; }
 34
 35        /// <summary>
 36        /// Gets or sets the body as a string.
 37        /// </summary>
 17438        public string Body { get; set; }
 39
 40        /// <summary>
 41        /// Gets or sets the body as a json object.
 42        /// </summary>
 11243        public object BodyAsJson { get; set; }
 44
 45        /// <summary>
 46        /// Gets or sets the body as bytes.
 47        /// </summary>
 12948        public byte[] BodyAsBytes { get; set; }
 49
 50        /// <summary>
 51        /// Gets or sets the body as a file.
 52        /// </summary>
 5653        public string BodyAsFile { get; set; }
 54
 55        /// <summary>
 56        /// Is the body as file cached?
 57        /// </summary>
 358        public bool? BodyAsFileIsCached { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets the body encoding.
 62        /// </summary>
 18163        public Encoding BodyEncoding { get; set; } = new UTF8Encoding(false);
 64
 65        /// <summary>
 66        /// Adds the header.
 67        /// </summary>
 68        /// <param name="name">The name.</param>
 69        /// <param name="value">The value.</param>
 70        public void AddHeader(string name, string value)
 171        {
 172            Headers.Add(name, new WireMockList<string>(value));
 173        }
 74
 75        /// <summary>
 76        /// Adds the header.
 77        /// </summary>
 78        /// <param name="name">The name.</param>
 79        /// <param name="values">The values.</param>
 80        public void AddHeader(string name, params string[] values)
 9181        {
 9182            Check.NotNullOrEmpty(values, nameof(values));
 83
 9184             var newHeaderValues = Headers.TryGetValue(name, out WireMockList<string> existingValues)
 9185                ? values.Union(existingValues).ToArray()
 9186                : values;
 87
 9188            Headers[name] = new WireMockList<string>(newHeaderValues);
 9189        }
 90    }
 91}