private object GetPowerAppsCdsDatabaseLanguagesAsync(OperationRunner context) { context.Logger.LogInformation("Getting PowerApps Common Data Services database languages..."); PowerAppsClient client = new PowerAppsClient(WizardContext.TokenProvider); client.SetLogger(context.Logger); return(client.GetCdsDatabaseLanguagesAsync( DataModel.InstallationConfiguration.PowerApps.SelectedLocation).Result); }
public void GetCdsDatabaseLanguagesAsyncSuccess() { string expectedLocation = "unitedstates"; string expectedRequestUri = $"https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/locations/{expectedLocation}/environmentLanguages?api-version=2016-11-01"; Dictionary <string, string> expectedLanguages = new Dictionary <string, string>() { { "location", expectedLocation }, { "name1", "1033" }, { "displayName1", "English" }, { "name2", "1025" }, { "displayName2", "Arabic" }, { "name3", "1069" }, { "displayName3", "euskara (euskara)" }, }; string responseFilePath = @"./data/templates/responses/powerApps/getCdsDatabaseLanguages.json"; HttpRequestMessage expectedRequest = TestHelper.CreateHttpRequest( HttpMethod.Get, expectedRequestUri); _httpClient.RegisterExpectedRequest(new ExpectedRequest(expectedRequest)); HttpResponseMessage expectedResponse = TestHelper.CreateHttpResponse( HttpStatusCode.OK, null, responseFilePath, "application/json", expectedLanguages); _httpClient.RegisterExpectedResponse( expectedRequestUri, new ExpectedResponse(expectedResponse)); IPowerAppsClient client = new PowerAppsClient(_tokenProvider); GetPowerAppsLanguagesResponse response = client.GetCdsDatabaseLanguagesAsync(expectedLocation).Result; Assert.IsNotNull(response, "The response should not be null!"); Assert.IsNotNull(response.Value, "The response Value member should not be null!"); Assert.AreEqual(3, response.Value.Length, $"Unexpected number of locations ('3' != '{response.Value.Length}')!"); Assert.AreEqual(expectedLanguages["name1"], response.Value[0].Name, $"Unexpected name for language 1 ('{expectedLanguages["name1"]}' != '{response.Value[0].Name}')"); Assert.IsNotNull(response.Value[0].Properties, "The response Value Properties member should not be null for language 1!"); Assert.AreEqual(expectedLanguages["displayName1"], response.Value[0].Properties.DisplayName, $"Unexpected display name for language 1 ('{expectedLanguages["displayName1"]}' != '{response.Value[0].Properties.DisplayName}')"); Assert.AreEqual(expectedLanguages["name2"], response.Value[1].Name, $"Unexpected name for language 2 ('{expectedLanguages["name2"]}' != '{response.Value[1].Name}')"); Assert.IsNotNull(response.Value[1].Properties, "The response Value Properties member should not be null for language 2!"); Assert.AreEqual(expectedLanguages["displayName2"], response.Value[1].Properties.DisplayName, $"Unexpected display name for language 2 ('{expectedLanguages["displayName2"]}' != '{response.Value[1].Properties.DisplayName}')"); Assert.AreEqual(expectedLanguages["name3"], response.Value[2].Name, $"Unexpected name for language 3 ('{expectedLanguages["name3"]}' != '{response.Value[2].Name}')"); Assert.IsNotNull(response.Value[2].Properties, "The response Value Properties member should not be null for language 3!"); Assert.AreEqual(expectedLanguages["displayName3"], response.Value[2].Properties.DisplayName, $"Unexpected display name for language 3 ('{expectedLanguages["displayName3"]}' != '{response.Value[2].Properties.DisplayName}')"); }