Пример #1
0
        public async Task GetSpecificResourceInGroupTest()
        {
            // Instantiate the tested calss
            TestContext.WriteLine($"Creating ResourcesRepository for {this.subscriptionId}...");
            var factory    = new Testee.RepositoryFactory(this.subscriptionId, this.resourceGroupName);
            var repoToTest = factory.CreateResourcesRepo(this.loggingBuilder);

            SetTesteeEnvironmentVariables(factory);

            // Get the resources in the resource group
            TestContext.WriteLine($"Trying to get {resourcesInGroup.Count} resources from {this.resourceGroupName}...");
            foreach (var resourceExpected in this.resourcesInGroup)
            {
                TestContext.WriteLine($"- Getting resource {resourceExpected.Id}...");

                // Execute the method to test
                var resourceAsIs = await repoToTest.GetByIdAsync(resourceExpected.Id);

                // The resource should have been found
                TestContext.WriteLine($"- Assertions for resource {resourceExpected.Id}...");
                Assert.IsNotNull(resourceAsIs);
                Assert.AreEqual(resourceExpected.Id, resourceAsIs.Id, true);
                Assert.AreEqual(resourceExpected.Name, resourceAsIs.Name, true);
                Assert.AreEqual(resourceExpected.RegionName, resourceAsIs.Location, true);
            }

            TestContext.WriteLine("Succeeded!");
        }
Пример #2
0
        public async Task CreateAdlsStorageAccountTestImpl(bool useTemplateStrategy)
        {
            // Instantiate the tested class
            TestContext.WriteLine($"Creating ADLS StorageRepository for {this.subscriptionId}...");
            var factory    = new Testee.RepositoryFactory(this.subscriptionId, this.resourceGroupName);
            var repoToTest = factory.CreateStorageRepo(this.loggingBuilder, useTemplateStrategy);

            SetTesteeEnvironmentVariables(factory);

            // Generate a unique name for the storage account
            var uniqueName = GenerateUniqueName("mszstdl");

            // Try to create that storage account
            TestContext.WriteLine($"Trying to create ADLS storage account in resource group {this.resourceGroupName}...");
            await repoToTest.CreateAsync(uniqueName, this.resourceGroup.RegionName, Testee.Interfaces.StorageType.Datalake, Testee.Sku.Standard, "http://azure-cli-2020-12-05-20-10-11");

            // Try to retrieve the storage account
            TestContext.WriteLine("Trying to find ADLS storage account in resource group {this.resourceGroupName}...");
            var foundAccount = await TestAzure.StorageAccounts.GetByResourceGroupAsync(this.resourceGroupName, uniqueName);

            Assert.IsNotNull(foundAccount);
            Assert.AreEqual(foundAccount.AccountStatuses.Primary.GetValueOrDefault(), Microsoft.Azure.Management.Storage.Fluent.Models.AccountStatus.Available);

            TestContext.WriteLine("Succeeded!");
        }
Пример #3
0
        public async Task GetAllResourcesInGroupTest()
        {
            // Instantiate the tested calss
            TestContext.WriteLine($"Creating ResourcesRepository for {this.subscriptionId}...");
            var factory    = new Testee.RepositoryFactory(this.subscriptionId, this.resourceGroupName);
            var repoToTest = factory.CreateResourcesRepo(this.loggingBuilder);

            SetTesteeEnvironmentVariables(factory);

            // Get the resources in the resource group
            TestContext.WriteLine($"Getting resources from resource group {this.resourceGroupName}...");
            var resourcesAsIs = await repoToTest.GetAllAsync();

            // It should return not null all the time and the number of resources should be equal to what the test determined in its initialization.
            TestContext.WriteLine("Test assertions...");
            Assert.IsNotNull(resourcesAsIs);
            Assert.AreEqual(resourcesInGroup.Count, resourcesAsIs.Count);

            // Compare the resources found ordered by ID
            resourcesAsIs.Sort(delegate(Testee.Entities.ResourceEntity a, Testee.Entities.ResourceEntity b)
            {
                return(string.Compare(a.Id, b.Id, StringComparison.InvariantCulture));
            });
            for (int i = 0; i < resourcesAsIs.Count; i++)
            {
                Assert.AreEqual(resourcesInGroup[i].Id, resourcesAsIs[i].Id, true);
                Assert.AreEqual(resourcesInGroup[i].Name, resourcesAsIs[i].Name, true);
                Assert.AreEqual(resourcesInGroup[i].RegionName, resourcesAsIs[i].Location, true);
            }

            TestContext.WriteLine("Succeeded!");
        }