< Summary

Class:Azure.Core.Pipeline.ThreadSafeRandom
Assembly:Azure.Core
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Pipeline\Internal\ThreadSafeRandom.cs
Covered lines:4
Uncovered lines:13
Coverable lines:17
Total lines:52
Line coverage:23.5% (4 of 17)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
Next()-0%100%
Next(...)-100%100%
Next(...)-0%100%
NextDouble()-0%100%
NextBytes(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\Pipeline\Internal\ThreadSafeRandom.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure.Core.Pipeline
 7{
 8    internal class ThreadSafeRandom : Random
 9    {
 21010        private readonly Random _random = new Random();
 11
 12        public override int Next()
 13        {
 014            lock (_random)
 15            {
 016                return _random.Next();
 17            }
 018        }
 19
 20        public override int Next(int minValue, int maxValue)
 21        {
 56422            lock (_random)
 23            {
 56424                return _random.Next(minValue, maxValue);
 25            }
 56426        }
 27
 28        public override int Next(int maxValue)
 29        {
 030            lock (_random)
 31            {
 032                return _random.Next(maxValue);
 33            }
 034        }
 35
 36        public override double NextDouble()
 37        {
 038            lock (_random)
 39            {
 040                return _random.NextDouble();
 41            }
 042        }
 43
 44        public override void NextBytes(byte[] buffer)
 45        {
 046            lock (_random)
 47            {
 048                _random.NextBytes(buffer);
 049            }
 050        }
 51    }
 52}