Summary

Class:WireMock.ResponseMessage
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\ResponseMessage.cs
Covered lines:18
Uncovered lines:3
Coverable lines:21
Total lines:95
Line coverage:85.7%
Branch coverage:50%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
AddHeader(...)0000
AddHeader(...)0010.5

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\ResponseMessage.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using System.Text;
 4using WireMock.Util;
 5using WireMock.Validation;
 6
 7namespace WireMock
 8{
 9    /// <summary>
 10    /// The ResponseMessage.
 11    /// </summary>
 12    public class ResponseMessage
 13    {
 14        /// <summary>
 15        /// Gets the headers.
 16        /// </summary>
 56217        public IDictionary<string, WireMockList<string>> Headers { get; set; } = new Dictionary<string, WireMockList<str
 18
 19        /// <summary>
 20        /// Gets or sets the status code.
 21        /// </summary>
 46422        public int StatusCode { get; set; } = 200;
 23
 24        /// <summary>
 25        /// Gets or sets the body.
 26        /// </summary>
 7227        public string BodyOriginal { get; set; }
 28
 29        /// <summary>
 30        /// Gets or sets the body destination (SameAsSource, String or Bytes).
 31        /// </summary>
 12332        public string BodyDestination { get; set; }
 33
 34        /// <summary>
 35        /// Gets or sets the body as a string.
 36        /// </summary>
 24937        public string Body { get; set; }
 38
 39        /// <summary>
 40        /// Gets or sets the body as a json object.
 41        /// </summary>
 28842        public object BodyAsJson { get; set; }
 43
 44        /// <summary>
 45        /// Gets or sets a value indicating whether child objects to be indented according to the Newtonsoft.Json.JsonTe
 46        /// </summary>
 3547        public bool? BodyAsJsonIndented { get; set; }
 48
 49        /// <summary>
 50        /// Gets or sets the body as bytes.
 51        /// </summary>
 16652        public byte[] BodyAsBytes { get; set; }
 53
 54        /// <summary>
 55        /// Gets or sets the body as a file.
 56        /// </summary>
 10857        public string BodyAsFile { get; set; }
 58
 59        /// <summary>
 60        /// Is the body as file cached?
 61        /// </summary>
 5962        public bool? BodyAsFileIsCached { get; set; }
 63
 64        /// <summary>
 65        /// Gets or sets the body encoding.
 66        /// </summary>
 48167        public Encoding BodyEncoding { get; set; } = new UTF8Encoding(false);
 68
 69        /// <summary>
 70        /// Adds the header.
 71        /// </summary>
 72        /// <param name="name">The name.</param>
 73        /// <param name="value">The value.</param>
 74        public void AddHeader(string name, string value)
 075        {
 076            Headers.Add(name, new WireMockList<string>(value));
 077        }
 78
 79        /// <summary>
 80        /// Adds the header.
 81        /// </summary>
 82        /// <param name="name">The name.</param>
 83        /// <param name="values">The values.</param>
 84        public void AddHeader(string name, params string[] values)
 10285        {
 10286            Check.NotNullOrEmpty(values, nameof(values));
 87
 10288            var newHeaderValues = Headers.TryGetValue(name, out WireMockList<string> existingValues)
 10289                ? values.Union(existingValues).ToArray()
 10290                : values;
 91
 10292            Headers[name] = new WireMockList<string>(newHeaderValues);
 10293        }
 94    }
 95}