< Summary

Class:Azure.Core.StringRequestContent
Assembly:Azure.DigitalTwins.Core
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\StringRequestContent.cs
Covered lines:9
Uncovered lines:1
Coverable lines:10
Total lines:40
Line coverage:90% (9 of 10)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
WriteToAsync()-100%100%
WriteTo(...)-100%100%
TryComputeLength(...)-100%100%
Dispose()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\StringRequestContent.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.IO;
 5using System.Text;
 6using System.Threading;
 7using System.Threading.Tasks;
 8
 9namespace Azure.Core
 10{
 11    internal class StringRequestContent : RequestContent
 12    {
 13        private readonly byte[] _bytes;
 14
 10415        public StringRequestContent(string value)
 16        {
 10417            _bytes = Encoding.UTF8.GetBytes(value);
 10418        }
 19
 20        public override async Task WriteToAsync(Stream stream, CancellationToken cancellation)
 21        {
 5222            await stream.WriteAsync(_bytes, 0, _bytes.Length, cancellation).ConfigureAwait(false);
 5223        }
 24
 25        public override void WriteTo(Stream stream, CancellationToken cancellation)
 26        {
 15627            stream.Write(_bytes, 0, _bytes.Length);
 15628        }
 29
 30        public override bool TryComputeLength(out long length)
 31        {
 20832            length = _bytes.Length;
 20833            return true;
 34        }
 35
 36        public override void Dispose()
 37        {
 038        }
 39    }
 40}