< Summary

Class:Azure.Core.TestFramework.RecordEntryMessage
Assembly:Azure.Core.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\RecordEntryMessage.cs
Covered lines:15
Uncovered lines:1
Coverable lines:16
Total lines:51
Line coverage:93.7% (15 of 16)
Covered branches:8
Total branches:8
Branch coverage:100% (8 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Headers()-0%100%
get_Body()-100%100%
TryGetContentType(...)-100%100%
IsTextContentType(...)-100%100%
TryGetBodyAsText(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\RecordEntryMessage.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Text;
 7using Azure.Core.Pipeline;
 8
 9namespace Azure.Core.TestFramework
 10{
 11    public class RecordEntryMessage
 12    {
 013        public SortedDictionary<string, string[]> Headers { get; set; } = new SortedDictionary<string, string[]>(StringC
 14
 304491615        public byte[] Body { get; set; }
 16
 17        public bool TryGetContentType(out string contentType)
 18        {
 3832419            contentType = null;
 3832420            if (Headers.TryGetValue("Content-Type", out var contentTypes) &&
 3832421                contentTypes.Length == 1)
 22            {
 2433223                contentType = contentTypes[0];
 2433224                return true;
 25            }
 1399226            return false;
 27        }
 28
 29        public bool IsTextContentType(out Encoding encoding)
 30        {
 1916231            encoding = null;
 1916232            return TryGetContentType(out string contentType) &&
 1916233                   ContentTypeUtilities.TryGetTextEncoding(contentType, out encoding);
 34        }
 35
 36        public bool TryGetBodyAsText(out string text)
 37        {
 1916238            text = null;
 39
 1916240            if (IsTextContentType(out Encoding encoding))
 41            {
 1205842                text = encoding.GetString(Body);
 43
 1205844                return true;
 45            }
 46
 710447            return false;
 48        }
 49
 50    }
 51}