| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using Azure.Core.TestFramework; |
| | | 6 | | |
| | | 7 | | namespace Azure.Core.Tests.TestFramework |
| | | 8 | | { |
| | | 9 | | public class TestRandom : Random |
| | | 10 | | { |
| | | 11 | | private readonly RecordedTestMode _mode; |
| | | 12 | | |
| | | 13 | | public TestRandom(RecordedTestMode mode, int seed) : |
| | 8369 | 14 | | base(seed) |
| | | 15 | | { |
| | 8369 | 16 | | _mode = mode; |
| | 8369 | 17 | | } |
| | | 18 | | |
| | | 19 | | public TestRandom(RecordedTestMode mode) : |
| | 2 | 20 | | base() |
| | | 21 | | { |
| | 2 | 22 | | _mode = mode; |
| | 2 | 23 | | } |
| | | 24 | | |
| | | 25 | | public Guid NewGuid() |
| | | 26 | | { |
| | 55804 | 27 | | if (_mode == RecordedTestMode.Live) |
| | | 28 | | { |
| | 0 | 29 | | return Guid.NewGuid(); |
| | | 30 | | } |
| | | 31 | | else |
| | | 32 | | { |
| | 55804 | 33 | | var bytes = new byte[16]; |
| | 55804 | 34 | | NextBytes(bytes); |
| | 55804 | 35 | | return new Guid(bytes); |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |
| | | 39 | | } |