< Summary

Class:Azure.Core.XmlWriterContent
Assembly:Azure.Data.Tables
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\AutoRest\XmlWriterContent.cs
Covered lines:15
Uncovered lines:3
Coverable lines:18
Total lines:53
Line coverage:83.3% (15 of 18)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
get_XmlWriter()-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\XmlWriterContent.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4#nullable enable
 5
 6using System.IO;
 7using System.Text;
 8using System.Threading;
 9using System.Threading.Tasks;
 10using System.Xml;
 11
 12namespace Azure.Core
 13{
 14    internal class XmlWriterContent : RequestContent
 15    {
 16        private readonly MemoryStream _stream;
 17        private readonly RequestContent _content;
 18
 819        public XmlWriterContent()
 20        {
 821            _stream = new MemoryStream();
 822            _content = Create(_stream);
 823            XmlWriter = new XmlTextWriter(_stream, Encoding.UTF8);
 824        }
 25
 4826        public XmlWriter XmlWriter { get; }
 27
 28        public override async Task WriteToAsync(Stream stream, CancellationToken cancellation)
 29        {
 430            XmlWriter.Flush();
 431            await _content.WriteToAsync(stream, cancellation).ConfigureAwait(false);
 432        }
 33
 34        public override void WriteTo(Stream stream, CancellationToken cancellation)
 35        {
 1236            XmlWriter.Flush();
 1237            _content.WriteTo(stream, cancellation);
 1238        }
 39
 40        public override bool TryComputeLength(out long length)
 41        {
 1642            XmlWriter.Flush();
 1643            length = _stream.Length;
 1644            return true;
 45        }
 46
 47        public override void Dispose()
 48        {
 049            _content.Dispose();
 050            XmlWriter.Dispose();
 051        }
 52    }
 53}