public async Task ValidateWaitOverride(RecordedTestMode mode) { // keep the curent test mode and restore it back when finished, otherwise it will invoke unnecessary clean-up var currentMode = Mode; Mode = mode; try { ManagementTestClient testClient = InstrumentClient(new ManagementTestClient()); TestResource testResource = testClient.GetTestResource(); Stopwatch sw = Stopwatch.StartNew(); testResource = (await testResource.GetLroAsync(WaitUntil.Completed)).Value; sw.Stop(); Assert.AreEqual("TestResourceProxy", testResource.GetType().Name); if (mode == RecordedTestMode.Playback) { Assert.Less(sw.ElapsedMilliseconds, 1000); } else { Assert.That(sw.ElapsedMilliseconds, Is.GreaterThanOrEqualTo(1000).Within(25)); } } finally { Mode = currentMode; } }
public async Task ValidateExceptionOperationWaitForCompletion() { ManagementTestClient client = InstrumentClient(new ManagementTestClient()); TestResource rgOp = client.GetTestResource(); var testResourceOp = await rgOp.GetLroAsync(WaitUntil.Completed, true); Assert.ThrowsAsync(typeof(ArgumentException), async() => await testResourceOp.WaitForCompletionAsync()); }
public async Task ValidateWaitForCompletion() { ManagementTestClient client = InstrumentClient(new ManagementTestClient()); TestResource rgOp = client.GetTestResource(); var testResourceOp = await rgOp.GetLroAsync(WaitUntil.Completed); TestResource testResource = await testResourceOp.WaitForCompletionAsync(); Assert.AreEqual("TestResourceProxy", testResource.GetType().Name); Assert.AreEqual("success", testResource.Method()); }