Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AsyncCollection in shared helper #7055

Merged
merged 3 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 38 additions & 0 deletions sdk/core/Azure.Core/tests/TestFramework/AsyncOnlyAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;

namespace Azure.Core.Testing
{

[AttributeUsage(AttributeTargets.Method|AttributeTargets.Class|AttributeTargets.Assembly, AllowMultiple=false, Inherited=false)]
public class AsyncOnlyAttribute : NUnitAttribute, IApplyToTest
{
#region IApplyToTest members

/// <summary>
/// Modifies a test by marking it as Ignored.
/// </summary>
/// <param name="test">The test to modify</param>
public void ApplyToTest(Test test)
{
if (test.RunState != RunState.NotRunnable)
{
// This is an unfortunate implementation but it's the only one I was able to figure out
string testParameters = test.FullName.Substring(test.ClassName.Length);
if (testParameters.StartsWith("(False"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth filing a bug to dig into further?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure there's a lot to dig into, this information doesn't seem to be on the test object, unfortunately. Let's see if it causes any issues like this.

{
test.RunState = RunState.Ignored;
}
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public override async IAsyncEnumerable<Page<T>> ByPage(string continuationToken
throw new InvalidOperationException("Calling ByPage with a continuationToken is not supported in the sync mode");
}

if (pageSizeHint != null)
{
throw new InvalidOperationException("Calling ByPage with a pageSizeHint is not supported in the sync mode");
}

foreach (Response<T> response in _enumerable)
{
yield return new Page<T>(new [] { response.Value}, null, response.GetRawResponse());
Expand Down
12 changes: 7 additions & 5 deletions sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ await TestHelper.AssertExpectedExceptionAsync<StorageRequestFailedException>(
[Test]
public async Task DeleteAsync_AccessConditions()
{
var garbageLeaseId = this.GetGarbageLeaseId();
var garbageLeaseId = this.GetGarbageLeaseId();
foreach (var parameters in this.AccessConditions_Data)
{
// Arrange
Expand Down Expand Up @@ -699,7 +699,7 @@ public async Task RenewLeaseAsync()
var duration = 15;

var leaseResponse = await container.GetLeaseClient(id).AcquireAsync(
duration: duration);
duration: duration);

// Act
var renewResponse = await container.GetLeaseClient(leaseResponse.Value.LeaseId).RenewAsync();
Expand Down Expand Up @@ -1150,6 +1150,7 @@ public async Task ListBlobsFlatSegmentAsync()
}

[Test]
[AsyncOnly]
public async Task ListBlobsFlatSegmentAsync_MaxResults()
{
using (this.GetNewContainer(out var container))
Expand All @@ -1159,12 +1160,12 @@ public async Task ListBlobsFlatSegmentAsync_MaxResults()

// Act
var page = await container.GetBlobsAsync().ByPage(pageSizeHint: 2).FirstAsync();

// Assert
Assert.AreEqual(2, page.Values.Count);
}
}

[Test]
public async Task ListBlobsFlatSegmentAsync_Metadata()
{
Expand Down Expand Up @@ -1351,6 +1352,7 @@ public async Task ListBlobsHierarchySegmentAsync()
}

[Test]
[AsyncOnly]
public async Task ListBlobsHierarchySegmentAsync_MaxResults()
{
using (this.GetNewContainer(out var container))
Expand All @@ -1368,7 +1370,7 @@ public async Task ListBlobsHierarchySegmentAsync_MaxResults()
Assert.AreEqual(2, page.Values.Count);
}
}

[Test]
public async Task ListBlobsHierarchySegmentAsync_Metadata()
{
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/Azure.Storage.Blobs/tests/ServiceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public async Task ListContainersSegmentAsync_Marker()
}

[Test]
[AsyncOnly]
public async Task ListContainersSegmentAsync_MaxResults()
{
var service = this.GetServiceClient_SharedKey();
Expand Down Expand Up @@ -138,6 +139,7 @@ public async Task ListContainersSegmentAsync_Metadata()
}

[Test]
[AsyncOnly]
public async Task ListContainersSegmentAsync_Error()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ await TestHelper.AssertExpectedExceptionAsync<StorageRequestFailedException>(
}

[Test]
[AsyncOnly]
public async Task ListHandles()
{
// Arrange
Expand Down
13 changes: 4 additions & 9 deletions sdk/storage/Azure.Storage.Files/tests/FileClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ await file.UploadRangeAsync(

// Act
var response = await file.DownloadAsync(range: new HttpRange(Constants.KB, data.LongLength));

// Assert
Assert.AreEqual(data.Length, response.Value.ContentLength);
var actual = new MemoryStream();
Expand Down Expand Up @@ -548,7 +548,7 @@ public async Task DownloadAsync_WithUnreliableConnection()
{
await fileFaulty.UploadRangeAsync(
writeType: FileRangeWriteType.Update,
range: new HttpRange(offset, dataSize),
range: new HttpRange(offset, dataSize),
content: stream);
}

Expand Down Expand Up @@ -661,7 +661,7 @@ public async Task UploadRangeAsync_WithUnreliableConnection()
var result = await fileFaulty.UploadRangeAsync(
writeType: FileRangeWriteType.Update,
range: new HttpRange(offset, dataSize),
content: stream,
content: stream,
progressHandler: progressHandler);

Assert.IsNotNull(result);
Expand Down Expand Up @@ -690,12 +690,7 @@ public async Task ListHandles()
using (this.GetNewFile(out var file))
{
// Act
var handles =
(await file.GetHandlesAsync()
.ByPage(pageSizeHint: 5)
.ToListAsync())
.SelectMany(p => p.Values)
.ToList();
var handles = await file.GetHandlesAsync().ToListAsync();
pakrym marked this conversation as resolved.
Show resolved Hide resolved

// Assert
Assert.AreEqual(0, handles.Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"ResponseBody": []
},
{
"RequestUri": "http:\u002f\u002fstorageteglazatesting.file.core.windows.net\u002ftest-share-68a732f4-c35d-d481-a001-24fe394833c2\u002ftest-directory-c0c37426-5a57-3ac5-9ccd-428aee0578a8\u002ftest-file-c5d79c40-7385-826b-eeeb-02f884e9731e?comp=listhandles\u0026maxresults=5",
"RequestUri": "http:\u002f\u002fstorageteglazatesting.file.core.windows.net\u002ftest-share-68a732f4-c35d-d481-a001-24fe394833c2\u002ftest-directory-c0c37426-5a57-3ac5-9ccd-428aee0578a8\u002ftest-file-c5d79c40-7385-826b-eeeb-02f884e9731e?comp=listhandles",
"RequestMethod": "GET",
"RequestHeaders": {
"Authorization": "Sanitized",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"ResponseBody": []
},
{
"RequestUri": "http:\u002f\u002fstorageteglazatesting.file.core.windows.net\u002ftest-share-a9daa292-8626-4059-fd38-24cc282d84cc\u002ftest-directory-c11c111d-9767-4f63-e5b4-02fbf11e3525\u002ftest-file-17afbdb5-c210-8565-363e-1d438bdc20a6?comp=listhandles\u0026maxresults=5",
"RequestUri": "http:\u002f\u002fstorageteglazatesting.file.core.windows.net\u002ftest-share-a9daa292-8626-4059-fd38-24cc282d84cc\u002ftest-directory-c11c111d-9767-4f63-e5b4-02fbf11e3525\u002ftest-file-17afbdb5-c210-8565-363e-1d438bdc20a6?comp=listhandles",
"RequestMethod": "GET",
"RequestHeaders": {
"Authorization": "Sanitized",
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/Azure.Storage.Queues/tests/ServiceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public async Task GetQueuesAsync_Marker()
}

[Test]
[AsyncOnly]
public async Task GetQueuesAsync_MaxResults()
{
var service = this.GetServiceClient_SharedKey();
Expand Down Expand Up @@ -103,6 +104,7 @@ public async Task GetQueuesAsync_Metadata()
}

[Test]
[AsyncOnly]
public async Task GetQueuesAsync_Error()
{
var service = this.GetServiceClient_SharedKey();
Expand Down