Пример #1
0
        /// <summary>
        /// Utility method to test Delete request for Tags Operation within tracked resources and proxy resources
        /// </summary>
        private async Task <TagsResource> DeleteTagsTest(string resourceScope = "")
        {
            var subscriptionScope = "//subscriptions/" + TestEnvironment.SubscriptionId;

            resourceScope = subscriptionScope + resourceScope;

            // using Tags.CreateOrUpdateAtScope to create two tags initially
            var tagsResource = new TagsResource(new Tags()
            {
                TagsValue = new Dictionary <string, string> {
                    { "tagKey1", "tagValue1" },
                    { "tagKey2", "tagValue2" }
                }
            });
            await TagsOperations.CreateOrUpdateAtScopeAsync(resourceScope, tagsResource);

            if (Mode == RecordedTestMode.Record)
            {
                Thread.Sleep(3 * 1000);
            }

            // try to delete existing tags
            await TagsOperations.DeleteAtScopeAsync(resourceScope);

            if (Mode == RecordedTestMode.Record)
            {
                Thread.Sleep(15 * 1000);
            }

            // after deletion, Get request should get 0 tags back
            var result = (await TagsOperations.GetAtScopeAsync(resourceScope)).Value;;

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Utility method to test Get request for Tags Operation within tracked resources and proxy resources
        /// </summary>
        private async void GetTagsTest(string resourceScope = "")
        {
            var subscriptionScope = "/subscriptions/" + TestEnvironment.SubscriptionId;

            resourceScope = subscriptionScope + resourceScope;

            // using Tags.CreateOrUpdateAtScope to create two tags initially
            var tagsResource = new TagsResource(new Tags()
            {
                TagsValue = new Dictionary <string, string> {
                    { "tagKey1", "tagValue1" },
                    { "tagKey2", "tagValue2" }
                }
            });
            await TagsOperations.CreateOrUpdateAtScopeAsync(resourceScope, tagsResource);

            if (Mode == RecordedTestMode.Record)
            {
                Thread.Sleep(3 * 1000);
            }

            // get request should return created TagsResource
            var getResponse = (await TagsOperations.GetAtScopeAsync(resourceScope)).Value;

            Assert.AreEqual(getResponse.Properties.TagsValue.Count(), tagsResource.Properties.TagsValue.Count());
            Assert.IsTrue(this.CompareTagsResource(tagsResource, getResponse));
        }