< Summary

Class:Azure.Core.Http.Multipart.MultipartBoundary
Assembly:Azure.Storage.Blobs.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Shared\MultipartBoundary.cs
Covered lines:24
Uncovered lines:2
Coverable lines:26
Total lines:76
Line coverage:92.3% (24 of 26)
Covered branches:9
Total branches:10
Branch coverage:90% (9 of 10)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-87.5%50%
Initialize(...)-100%100%
GetSkipValue(...)-100%100%
get_ExpectLeadingCrlf()-0%100%
set_ExpectLeadingCrlf(...)-100%100%
get_BoundaryBytes()-100%100%
get_FinalBoundaryLength()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.Storage.Blobs.Batch\src\Shared\MultipartBoundary.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// Copied from https://github.com/aspnet/AspNetCore/tree/master/src/Http/WebUtilities/src
 5
 6using System;
 7using System.Text;
 8
 9#pragma warning disable IDE0016 // Null check can be simplified
 10
 11namespace Azure.Core.Http.Multipart
 12{
 13    internal class MultipartBoundary
 14    {
 8815        private readonly int[] _skipTable = new int[256];
 16        private readonly string _boundary;
 17        private bool _expectLeadingCrlf;
 18
 8819        public MultipartBoundary(string boundary, bool expectLeadingCrlf = true)
 20        {
 8821            if (boundary == null)
 22            {
 023                throw new ArgumentNullException(nameof(boundary));
 24            }
 25
 8826            _boundary = boundary;
 8827            _expectLeadingCrlf = expectLeadingCrlf;
 8828            Initialize(_boundary, _expectLeadingCrlf);
 8829        }
 30
 31        private void Initialize(string boundary, bool expectLeadingCrlf)
 32        {
 17633            if (expectLeadingCrlf)
 34            {
 8835                BoundaryBytes = Encoding.UTF8.GetBytes("\r\n--" + boundary);
 36            }
 37            else
 38            {
 8839                BoundaryBytes = Encoding.UTF8.GetBytes("--" + boundary);
 40            }
 17641            FinalBoundaryLength = BoundaryBytes.Length + 2; // Include the final '--' terminator.
 42
 17643            var length = BoundaryBytes.Length;
 9046444            for (var i = 0; i < _skipTable.Length; ++i)
 45            {
 4505646                _skipTable[i] = length;
 47            }
 1900848            for (var i = 0; i < length; ++i)
 49            {
 932850                _skipTable[BoundaryBytes[i]] = Math.Max(1, length - 1 - i);
 51            }
 17652        }
 53
 54        public int GetSkipValue(byte input)
 55        {
 782656            return _skipTable[input];
 57        }
 58
 59        public bool ExpectLeadingCrlf
 60        {
 061            get { return _expectLeadingCrlf; }
 62            set
 63            {
 127264                if (value != _expectLeadingCrlf)
 65                {
 8866                    _expectLeadingCrlf = value;
 8867                    Initialize(_boundary, _expectLeadingCrlf);
 68                }
 127269            }
 70        }
 71
 1387672        public byte[] BoundaryBytes { get; private set; }
 73
 283674        public int FinalBoundaryLength { get; private set; }
 75    }
 76}