From 7507b50f047a2c64a601cb861a921263933ea7e6 Mon Sep 17 00:00:00 2001 From: tg-msft Date: Thu, 1 Aug 2019 14:55:35 -0700 Subject: [PATCH] Remove the default Operation ctor I missed the default ctor when adding Id as part of #7061 --- sdk/core/Azure.Core/src/OperationOfT.cs | 2 -- sdk/core/Azure.Core/tests/OperationTests.cs | 13 ++++++------- .../Azure.Core/tests/TestFramework/TestOperation.cs | 11 +++++------ 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sdk/core/Azure.Core/src/OperationOfT.cs b/sdk/core/Azure.Core/src/OperationOfT.cs index cd8cf19bf4a95..3f7b804677c51 100644 --- a/sdk/core/Azure.Core/src/OperationOfT.cs +++ b/sdk/core/Azure.Core/src/OperationOfT.cs @@ -122,8 +122,6 @@ public virtual async ValueTask> WaitCompletionAsync(CancellationToke /// public abstract Response UpdateStatus(CancellationToken cancellationToken = default); - protected Operation() { } - [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => base.Equals(obj); diff --git a/sdk/core/Azure.Core/tests/OperationTests.cs b/sdk/core/Azure.Core/tests/OperationTests.cs index 516458f63a9fb..4fda706dd104f 100644 --- a/sdk/core/Azure.Core/tests/OperationTests.cs +++ b/sdk/core/Azure.Core/tests/OperationTests.cs @@ -21,7 +21,7 @@ public async Task WaitCompletionAsync() var testResult = 100; var testResponse = new MockResponse(200); - var operation = new TestOperation(TimeSpan.FromMilliseconds(10), testResult, testResponse); + var operation = new TestOperation("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse); operation.PollingInterval = TimeSpan.FromMilliseconds(1); operation.UpdateCalled = () => { updateCalled++; }; @@ -45,7 +45,7 @@ public async Task UpdateStatusAsync() var testResult = 100; var testResponse = new MockResponse(200); - var operation = new TestOperation(TimeSpan.FromMilliseconds(10), testResult, testResponse); + var operation = new TestOperation("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse); operation.UpdateCalled = () => { updateCalled++; }; while (!operation.HasValue) @@ -69,7 +69,7 @@ public void UpdateStatus() var testResult = 10; var testResponse = new MockResponse(200); - var operation = new TestOperation(TimeSpan.FromMilliseconds(10), testResult, testResponse); + var operation = new TestOperation("operation-id", TimeSpan.FromMilliseconds(10), testResult, testResponse); operation.UpdateCalled = () => { updateCalled++; }; while (!operation.HasValue) @@ -94,7 +94,7 @@ public void Cancellation() int updateCalled = 0; - var operation = new TestOperation(TimeSpan.FromMilliseconds(1000), 100, null); + var operation = new TestOperation("operation-id", TimeSpan.FromMilliseconds(1000), 100, null); operation.PollingInterval = TimeSpan.FromMilliseconds(10); operation.UpdateCalled = () => { updateCalled++; }; @@ -111,7 +111,7 @@ public void Cancellation() [Test] public void NotCompleted() { - var operation = new TestOperation(TimeSpan.FromMilliseconds(1000), 100, null); + var operation = new TestOperation("operation-id", TimeSpan.FromMilliseconds(1000), 100, null); Assert.IsFalse(operation.HasCompleted); Assert.IsFalse(operation.HasValue); Assert.Throws(() => @@ -124,9 +124,8 @@ public void NotCompleted() public void OperationId() { string testId = "operation-id"; - var operation = new TestOperation(testId); + var operation = new TestOperation(testId, TimeSpan.Zero, 0, null); Assert.AreEqual(testId, operation.Id); } } } - diff --git a/sdk/core/Azure.Core/tests/TestFramework/TestOperation.cs b/sdk/core/Azure.Core/tests/TestFramework/TestOperation.cs index e03c21b13dfaa..163a32c380726 100644 --- a/sdk/core/Azure.Core/tests/TestFramework/TestOperation.cs +++ b/sdk/core/Azure.Core/tests/TestFramework/TestOperation.cs @@ -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; @@ -19,12 +22,8 @@ public sealed class TestOperation : Operation 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;