Esempio n. 1
0
        private object GetPowerAppsEnvironmentsAsync(OperationRunner context)
        {
            PowerAppsClient client = new PowerAppsClient(WizardContext.TokenProvider);

            client.SetLogger(context.Logger);

            return((GetPowerAppsEnvironmentsResponse)client.GetEnvironmentsAsync().Result);
        }
        public void GetEnvironmentsAsyncWithIdSuccess()
        {
            string expectedEnvironmentName = Guid.NewGuid().ToString();
            string expectedLocation        = "unitedstates";
            string expectedDisplayName     = "TestEnvironment";
            string expectedResourceId      = Guid.NewGuid().ToString();
            string expectedFriendlyName    = "TestEnvironment";
            string expectedUniqueName      = "orgtest4";
            string expectedDomainName      = "orgtest5";
            string expectedRequestUri      = $"https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments/{expectedEnvironmentName}?$expand=permissions&api-version=2016-11-01";
            string responseFilePath        = @"./data/templates/responses/powerApps/environment.json";

            HttpRequestMessage expectedRequest = TestHelper.CreateHttpRequest(
                HttpMethod.Get,
                expectedRequestUri);

            _httpClient.RegisterExpectedRequest(new ExpectedRequest(expectedRequest));

            HttpResponseMessage expectedResponse = TestHelper.CreateHttpResponse(
                HttpStatusCode.OK,
                null,
                responseFilePath,
                "application/json",
                new Dictionary <string, string>()
            {
                { "environmentName", expectedEnvironmentName },
                { "location", expectedLocation },
                { "displayName", expectedDisplayName },
                { "crmResourceId", expectedResourceId },
                { "crmFriendlyName", expectedFriendlyName },
                { "crmUniqueName", expectedUniqueName },
                { "crmDomainName", expectedDomainName },
            });

            _httpClient.RegisterExpectedResponse(
                expectedRequestUri,
                new ExpectedResponse(expectedResponse));

            IPowerAppsClient client = new PowerAppsClient(_tokenProvider);

            PowerAppsEnvironment response = (PowerAppsEnvironment)client.GetEnvironmentsAsync(expectedEnvironmentName).Result;

            Assert.IsNotNull(response, "The response should not be null!");
            Assert.IsNotNull(response.Properties, "The response Properties member should not be null!");
            Assert.AreEqual(expectedEnvironmentName, response.Name, $"Unexpected name ('{expectedEnvironmentName}' != '{response.Name}')");
            Assert.AreEqual(expectedLocation, response.Location, $"Unexpected location ('{expectedLocation}' != '{response.Location}')");
            Assert.AreEqual(expectedDisplayName, response.Properties.DisplayName, $"Unexpected location ('{expectedDisplayName}' != '{response.Properties.DisplayName}')");
            Assert.AreEqual(expectedDisplayName, response.Properties.DisplayName, $"Unexpected location ('{expectedDisplayName}' != '{response.Properties.DisplayName}')");
            Assert.IsNotNull(response.Properties.LinkedEnvironmentMetadata, "The response Properties.LinkedEnvironmentMetadata member should not be null!");
            Assert.AreEqual(expectedResourceId, response.Properties.LinkedEnvironmentMetadata.ResourceId, $"Unexpected resource id ('{expectedResourceId}' != '{response.Properties.LinkedEnvironmentMetadata.ResourceId}')");
            Assert.AreEqual(expectedFriendlyName, response.Properties.LinkedEnvironmentMetadata.FriendlyName, $"Unexpected friendly name ('{expectedFriendlyName}' != '{response.Properties.LinkedEnvironmentMetadata.FriendlyName}')");
            Assert.AreEqual(expectedUniqueName, response.Properties.LinkedEnvironmentMetadata.UniqueName, $"Unexpected unique name ('{expectedUniqueName}' != '{response.Properties.LinkedEnvironmentMetadata.UniqueName}')");
            Assert.AreEqual(expectedDomainName, response.Properties.LinkedEnvironmentMetadata.DomainName, $"Unexpected domain name ('{expectedDomainName}' != '{response.Properties.LinkedEnvironmentMetadata.DomainName}')");
        }