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

Remove the default Operation ctor #7083

Merged
merged 1 commit into from
Aug 1, 2019
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
2 changes: 0 additions & 2 deletions sdk/core/Azure.Core/src/OperationOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public virtual async ValueTask<Response<T>> WaitCompletionAsync(CancellationToke
/// </remarks>
public abstract Response UpdateStatus(CancellationToken cancellationToken = default);

protected Operation() { }

[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => base.Equals(obj);

Expand Down
13 changes: 6 additions & 7 deletions sdk/core/Azure.Core/tests/OperationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task WaitCompletionAsync()
var testResult = 100;
var testResponse = new MockResponse(200);

var operation = new TestOperation<int>(TimeSpan.FromMilliseconds(10), testResult, testResponse);
var operation = new TestOperation<int>("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse);
operation.PollingInterval = TimeSpan.FromMilliseconds(1);
operation.UpdateCalled = () => { updateCalled++; };

Expand All @@ -45,7 +45,7 @@ public async Task UpdateStatusAsync()
var testResult = 100;
var testResponse = new MockResponse(200);

var operation = new TestOperation<int>(TimeSpan.FromMilliseconds(10), testResult, testResponse);
var operation = new TestOperation<int>("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse);
operation.UpdateCalled = () => { updateCalled++; };

while (!operation.HasValue)
Expand All @@ -69,7 +69,7 @@ public void UpdateStatus()
var testResult = 10;
var testResponse = new MockResponse(200);

var operation = new TestOperation<int>(TimeSpan.FromMilliseconds(10), testResult, testResponse);
var operation = new TestOperation<int>("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse);
operation.UpdateCalled = () => { updateCalled++; };

while (!operation.HasValue)
Expand All @@ -94,7 +94,7 @@ public void Cancellation()

int updateCalled = 0;

var operation = new TestOperation<int>(TimeSpan.FromMilliseconds(1000), 100, null);
var operation = new TestOperation<int>("operation-id", TimeSpan.FromMilliseconds(1000), 100, null);
operation.PollingInterval = TimeSpan.FromMilliseconds(10);
operation.UpdateCalled = () => { updateCalled++; };

Expand All @@ -111,7 +111,7 @@ public void Cancellation()
[Test]
public void NotCompleted()
{
var operation = new TestOperation<int>(TimeSpan.FromMilliseconds(1000), 100, null);
var operation = new TestOperation<int>("operation-id", TimeSpan.FromMilliseconds(1000), 100, null);
Assert.IsFalse(operation.HasCompleted);
Assert.IsFalse(operation.HasValue);
Assert.Throws<InvalidOperationException>(() =>
Expand All @@ -124,9 +124,8 @@ public void NotCompleted()
public void OperationId()
{
string testId = "operation-id";
var operation = new TestOperation<int>(testId);
var operation = new TestOperation<int>(testId, TimeSpan.Zero, 0, null);
Assert.AreEqual(testId, operation.Id);
}
}
}

11 changes: 5 additions & 6 deletions sdk/core/Azure.Core/tests/TestFramework/TestOperation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -19,12 +22,8 @@ public sealed class TestOperation<T> : Operation<T>

public Action UpdateCalled { get; set; }

internal TestOperation(string id)
internal TestOperation(string id, TimeSpan after, T finalResult, Response finalResponse)
: base(id)
{
}

internal TestOperation(TimeSpan after, T finalResult, Response finalResponse)
{
_after = after;
_finalResult = finalResult;
Expand Down