Exemplo n.º 1
0
        public void ValidateExceptionOperation()
        {
            ManagementTestClient client = InstrumentClient(new ManagementTestClient());
            TestResource         rgOp   = client.GetTestResource();

            Assert.ThrowsAsync(typeof(ArgumentException), async() => await rgOp.GetLroExceptionAsync(WaitUntil.Completed));
        }
Exemplo n.º 2
0
        public void ValidateExceptionResponse()
        {
            ManagementTestClient client = InstrumentClient(new ManagementTestClient());
            TestResource         rgOp   = client.GetTestResource();

            Assert.ThrowsAsync(typeof(ArgumentException), async() => await rgOp.GetResponseExceptionAsync());
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        public void ValidateInstrumentGetOperations()
        {
            ManagementTestClient client = InstrumentClient(new ManagementTestClient());
            var testResource            = client.GetTestResource();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            Assert.AreEqual("success", testResource.Method());
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        public void ValidateForwardClientCallTrue()
        {
            ManagementTestClient client       = InstrumentClient(new ManagementTestClient());
            TestResource         testResource = client.GetTestResource();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            Assert.DoesNotThrowAsync(async() => testResource = await testResource.GetForwardsCallTrueAsync());
            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
        }
        public async Task ValidateLroWrapper()
        {
            ManagementTestClient client       = InstrumentClient(new ManagementTestClient());
            TestResource         rgOp         = client.GetTestResource();
            TestResource         testResource = await rgOp.LroWrapperAsync();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            Assert.AreEqual("success", testResource.Method());
        }
Exemplo n.º 8
0
        public void ValidateForwardClientCallDefault()
        {
            ManagementTestClient client       = InstrumentClient(new ManagementTestClient());
            TestResource         testResource = client.GetTestResource();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            var ex = Assert.ThrowsAsync <InvalidOperationException>(async() => testResource = await testResource.GetForwardsCallDefaultAsync());

            Assert.AreEqual(ex.Message, "Expected some diagnostic scopes to be created, found none");
        }
Exemplo n.º 9
0
        public void ValidateForwardClientCallFalse()
        {
            ManagementTestClient client       = InstrumentClient(new ManagementTestClient());
            TestResource         testResource = client.GetTestResource();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            var ex = Assert.ThrowsAsync <InvalidOperationException>(async() => testResource = await testResource.GetForwardsCallFalseAsync());

            StringAssert.Contains("Expected some diagnostic scopes to be created other than the Azure.Core scopes", ex.Message);
        }
Exemplo n.º 10
0
        public async Task ValidateStartLroWrapper()
        {
            ManagementTestClient client = InstrumentClient(new ManagementTestClient());
            TestResource         rgOp   = client.GetTestResource();
            var testResourceOp          = await rgOp.StartLroWrapperAsync(WaitUntil.Completed);

            TestResource testResource = await testResourceOp.WaitForCompletionAsync();

            Assert.AreEqual("TestResourceProxy", testResource.GetType().Name);
            Assert.AreEqual("success", testResource.Method());
        }
        public async Task ValidateSkipWait()
        {
            ManagementTestClient client       = InstrumentClient(new ManagementTestClient());
            TestResource         rgOp         = client.GetTestResource();
            Stopwatch            timer        = Stopwatch.StartNew();
            TestResource         testResource = await rgOp.LroWrapperAsync();

            timer.Stop();
            //method waits for 10 seconds so timer should easily be less than half of that if we skip
            Assert.IsTrue(timer.ElapsedMilliseconds < 5000, $"WaitForCompletion took {timer.ElapsedMilliseconds}ms");
        }