< Summary

Class:Azure.NoBodyResponse`1
Assembly:Azure.Storage.Blobs.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\NoBodyResponse{T}.cs
Covered lines:0
Uncovered lines:10
Coverable lines:10
Total lines:45
Line coverage:0% (0 of 10)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
get_Value()-0%100%
GetRawResponse()-0%100%
ToString()-0%100%
get_Status()-0%100%
.ctor(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Shared\NoBodyResponse{T}.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure
 7{
 8    internal class NoBodyResponse<T> : Response<T>
 9    {
 10        private readonly Response _response;
 11
 012        public NoBodyResponse(Response response)
 13        {
 014            _response = response;
 015        }
 16
 17        public override T Value
 18        {
 19            get
 20            {
 021                throw new ResponseBodyNotFoundException(_response.Status, _response.ReasonPhrase);
 22            }
 23        }
 24
 025        public override Response GetRawResponse() => _response;
 26
 27        public override string ToString()
 28        {
 029            return $"Status: {GetRawResponse().Status}, Service returned no content";
 30        }
 31
 32#pragma warning disable CA1064 // Exceptions should be public
 33        private class ResponseBodyNotFoundException : Exception
 34#pragma warning restore CA1064 // Exceptions should be public
 35        {
 036            public int Status { get; }
 37
 38            public ResponseBodyNotFoundException(int status, string message)
 039                : base(message)
 40            {
 041                Status = status;
 042            }
 43        }
 44    }
 45}