< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Value()-100%100%
GetRawResponse()-100%100%
ToString()-0%100%
get_Status()-0%100%
.ctor(...)-100%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
 11212        public NoBodyResponse(Response response)
 13        {
 11214            _response = response;
 11215        }
 16
 17        public override T Value
 18        {
 19            get
 20            {
 6421                throw new ResponseBodyNotFoundException(_response.Status, _response.ReasonPhrase);
 22            }
 23        }
 24
 11625        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)
 6439                : base(message)
 40            {
 6441                Status = status;
 6442            }
 43        }
 44    }
 45}