Skip to content
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Queues/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/storage/Azure.Storage.Queues",
"Tag": "net/storage/Azure.Storage.Queues_95435e3a7a"
"Tag": "net/storage/Azure.Storage.Queues_1029a3ae08"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using System.ComponentModel;

namespace Azure.Storage.Queues.Models
{
Expand All @@ -18,8 +19,14 @@ public class QueueProperties
/// <summary>
/// The approximate number of messages in the queue. This number is not lower than the actual number of messages in the queue, but could be higher.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public int ApproximateMessagesCount { get; internal set; }

/// <summary>
/// The approximate number of messages in the queue. This number is not lower than the actual number of messages in the queue, but could be higher.
/// </summary>
public long ApproximateMessagesCountLong { get; internal set; }

/// <summary>
/// Creates a new QueueProperties instance
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static QueueItem QueueItem(
/// <summary>
/// Creates a new QueueProperties instance for mocking.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static QueueProperties QueueProperties(
IDictionary<string, string> metadata,
int approximateMessagesCount)
Expand All @@ -132,6 +133,20 @@ public static QueueProperties QueueProperties(
};
}

/// <summary>
/// Creates a new QueueProperties instance for mocking.
/// </summary>
public static QueueProperties QueueProperties(
IDictionary<string, string> metadata,
long approximateMessagesCount)
{
return new QueueProperties()
{
Metadata = metadata,
ApproximateMessagesCountLong = approximateMessagesCount,
};
}

/// <summary>
/// Creates a new QueueServiceStatistics instance for mocking.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion sdk/storage/Azure.Storage.Queues/src/QueueClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,8 @@ private async Task<Response<QueueProperties>> GetPropertiesInternal(

QueueProperties queueProperties = new QueueProperties
{
ApproximateMessagesCount = response.Headers.ApproximateMessagesCount.GetValueOrDefault(),
ApproximateMessagesCount = (int)response.Headers.ApproximateMessagesCount.GetValueOrDefault(),
ApproximateMessagesCountLong = response.Headers.ApproximateMessagesCount.GetValueOrDefault(),
Metadata = response.Headers.Metadata
};

Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/Azure.Storage.Queues/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Run `dotnet build /t:GenerateCode` to generate code.

``` yaml
input-file:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/5da3c08b92d05858b728b013b69502dc93485373/specification/storage/data-plane/Microsoft.QueueStorage/stable/2018-03-28/queue.json
- C:\azure-rest-api-specs\specification\storage\data-plane\Microsoft.QueueStorage\stable\2018-03-28\queue.json
Comment thread
nickliu-msft marked this conversation as resolved.
Outdated
generation1-convenience-client: true
# https://github.com/Azure/autorest/issues/4075
skip-semantics-validation: true
Expand Down
24 changes: 24 additions & 0 deletions sdk/storage/Azure.Storage.Queues/tests/QueueClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,30 @@ public async Task GetPropertiesAsync()
Assert.IsNotNull(queueProperties);
}

[TestCase(0)]
[TestCase(5)]
[TestCase(10)]
[RecordedTest]
public async Task GetPropertiesAsync_ApproximateMessagesCountLong(int messageCount)
{
// Arrange
await using DisposingQueue test = await GetTestQueueAsync();

// Act: Enqueue messages
for (int i = 0; i < messageCount; i++)
{
await test.Queue.SendMessageAsync($"Message {i + 1}");
}

// Fetch queue properties
Response<Models.QueueProperties> queueProperties = await test.Queue.GetPropertiesAsync();

// Assert
Assert.IsNotNull(queueProperties);
Assert.AreEqual(messageCount, queueProperties.Value.ApproximateMessagesCount);
Assert.AreEqual(messageCount, queueProperties.Value.ApproximateMessagesCountLong);
}

[RecordedTest]
public async Task GetPropertiesAsync_Error()
{
Expand Down
Loading