Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct StorageTransferOptions : IEquatable<StorageTransferOptions>
[EditorBrowsable(EditorBrowsableState.Never)]
public int? MaximumTransferLength
{
get => (int?)MaximumTransferSize;
get => checked((int?)MaximumTransferSize);
set => MaximumTransferSize = value;
}

Expand All @@ -43,7 +43,7 @@ public int? MaximumTransferLength
[EditorBrowsable(EditorBrowsableState.Never)]
public int? InitialTransferLength
{
get => (int?)InitialTransferSize;
get => checked((int?)InitialTransferSize);
set => InitialTransferSize = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;

namespace Azure.Storage.Tests
{
public class StorageTransferOptionsTests
{
/// <summary>
/// Tests non-throwing cases for backwards compatibility of int? facade
/// <see cref="StorageTransferOptions.MaximumTransferLength"/>.
/// </summary>
/// <param name="realSize"></param>
[TestCase(default)]
[TestCase(1)]
[TestCase(int.MaxValue)]
public void MaxTransferLengthBackCompatTest(long? realSize)
{
var options = new StorageTransferOptions
{
MaximumTransferSize = realSize
};

Assert.AreEqual(options.MaximumTransferSize, realSize);
Assert.AreEqual(options.MaximumTransferLength, realSize);
}

/// <summary>
/// Tests throwing cases for backwards compatibility of int? facade
/// <see cref="StorageTransferOptions.MaximumTransferLength"/>.
/// </summary>
/// <param name="realSize"></param>
[TestCase(int.MaxValue + 1L)]
[TestCase(long.MaxValue)]
public void MaxTransferLengthBackCompatOverflowTest(long? realSize)
{
var options = new StorageTransferOptions
{
MaximumTransferSize = realSize
};

Assert.AreEqual(options.MaximumTransferSize, realSize);
Assert.Throws<OverflowException>(() => _ = options.MaximumTransferLength);
}

/// <summary>
/// Tests non-throwing cases for backwards compatibility of int? facade
/// <see cref="StorageTransferOptions.MaximumTransferLength"/>.
/// </summary>
/// <param name="realSize"></param>
[TestCase(default)]
[TestCase(1)]
[TestCase(int.MaxValue)]
public void InitialTransferLengthBackCompatTest(long? realSize)
{
var options = new StorageTransferOptions
{
InitialTransferSize = realSize
};

Assert.AreEqual(options.InitialTransferSize, realSize);
Assert.AreEqual(options.InitialTransferLength, realSize);
}

/// <summary>
/// Tests throwing cases for backwards compatibility of int? facade
/// <see cref="StorageTransferOptions.MaximumTransferLength"/>.
/// </summary>
/// <param name="realSize"></param>
[TestCase(int.MaxValue + 1L)]
[TestCase(long.MaxValue)]
public void InitialTransferLengthBackCompatOverflowTest(long? realSize)
{
var options = new StorageTransferOptions
{
InitialTransferSize = realSize
};

Assert.AreEqual(options.InitialTransferSize, realSize);
Assert.Throws<OverflowException>(() => _ = options.InitialTransferLength);
}
}
}