|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | +using NUnit.Framework; |
| 10 | + |
| 11 | +namespace Azure.Storage.Tests |
| 12 | +{ |
| 13 | + public class StorageTransferOptionsTests |
| 14 | + { |
| 15 | + /// <summary> |
| 16 | + /// Tests non-throwing cases for backwards compatibility of int? facade |
| 17 | + /// <see cref="StorageTransferOptions.MaximumTransferLength"/>. |
| 18 | + /// </summary> |
| 19 | + /// <param name="realSize"></param> |
| 20 | + [TestCase(default)] |
| 21 | + [TestCase(1)] |
| 22 | + [TestCase(int.MaxValue)] |
| 23 | + public void MaxTransferLengthBackCompatTest(long? realSize) |
| 24 | + { |
| 25 | + var options = new StorageTransferOptions |
| 26 | + { |
| 27 | + MaximumTransferSize = realSize |
| 28 | + }; |
| 29 | + |
| 30 | + Assert.AreEqual(options.MaximumTransferSize, realSize); |
| 31 | + Assert.AreEqual(options.MaximumTransferLength, realSize); |
| 32 | + } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Tests throwing cases for backwards compatibility of int? facade |
| 36 | + /// <see cref="StorageTransferOptions.MaximumTransferLength"/>. |
| 37 | + /// </summary> |
| 38 | + /// <param name="realSize"></param> |
| 39 | + [TestCase(int.MaxValue + 1L)] |
| 40 | + [TestCase(long.MaxValue)] |
| 41 | + public void MaxTransferLengthBackCompatOverflowTest(long? realSize) |
| 42 | + { |
| 43 | + var options = new StorageTransferOptions |
| 44 | + { |
| 45 | + MaximumTransferSize = realSize |
| 46 | + }; |
| 47 | + |
| 48 | + Assert.AreEqual(options.MaximumTransferSize, realSize); |
| 49 | + Assert.Throws<OverflowException>(() => _ = options.MaximumTransferLength); |
| 50 | + } |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Tests non-throwing cases for backwards compatibility of int? facade |
| 54 | + /// <see cref="StorageTransferOptions.MaximumTransferLength"/>. |
| 55 | + /// </summary> |
| 56 | + /// <param name="realSize"></param> |
| 57 | + [TestCase(default)] |
| 58 | + [TestCase(1)] |
| 59 | + [TestCase(int.MaxValue)] |
| 60 | + public void InitialTransferLengthBackCompatTest(long? realSize) |
| 61 | + { |
| 62 | + var options = new StorageTransferOptions |
| 63 | + { |
| 64 | + InitialTransferSize = realSize |
| 65 | + }; |
| 66 | + |
| 67 | + Assert.AreEqual(options.InitialTransferSize, realSize); |
| 68 | + Assert.AreEqual(options.InitialTransferLength, realSize); |
| 69 | + } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Tests throwing cases for backwards compatibility of int? facade |
| 73 | + /// <see cref="StorageTransferOptions.MaximumTransferLength"/>. |
| 74 | + /// </summary> |
| 75 | + /// <param name="realSize"></param> |
| 76 | + [TestCase(int.MaxValue + 1L)] |
| 77 | + [TestCase(long.MaxValue)] |
| 78 | + public void InitialTransferLengthBackCompatOverflowTest(long? realSize) |
| 79 | + { |
| 80 | + var options = new StorageTransferOptions |
| 81 | + { |
| 82 | + InitialTransferSize = realSize |
| 83 | + }; |
| 84 | + |
| 85 | + Assert.AreEqual(options.InitialTransferSize, realSize); |
| 86 | + Assert.Throws<OverflowException>(() => _ = options.InitialTransferLength); |
| 87 | + } |
| 88 | + } |
| 89 | +} |
0 commit comments