public void GetCdsDatabaseCurrenciesAsyncSuccess() { string expectedLocation = "unitedstates"; string expectedRequestUri = $"https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/locations/{expectedLocation}/environmentCurrencies?api-version=2016-11-01"; Dictionary <string, string> expectedCurrencies = new Dictionary <string, string>() { { "location", expectedLocation }, { "name1", "XCD" }, { "code1", "XCD" }, { "symbol1", "EC$" }, { "name2", "USD" }, { "code2", "USD" }, { "symbol2", "US$" }, { "name3", "AED" }, { "code3", "AED" }, { "symbol3", "د.إ." }, }; string responseFilePath = @"./data/templates/responses/powerApps/getCdsDatabaseCurrencies.json"; HttpRequestMessage expectedRequest = TestHelper.CreateHttpRequest( HttpMethod.Get, expectedRequestUri); _httpClient.RegisterExpectedRequest(new ExpectedRequest(expectedRequest)); HttpResponseMessage expectedResponse = TestHelper.CreateHttpResponse( HttpStatusCode.OK, null, responseFilePath, "application/json", expectedCurrencies); _httpClient.RegisterExpectedResponse( expectedRequestUri, new ExpectedResponse(expectedResponse)); IPowerAppsClient client = new PowerAppsClient(_tokenProvider); GetPowerAppsCurrenciesResponse response = client.GetCdsDatabaseCurrenciesAsync(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(expectedCurrencies["name1"], response.Value[0].Name, $"Unexpected name for currency 1 ('{expectedCurrencies["name1"]}' != '{response.Value[0].Name}')"); Assert.IsNotNull(response.Value[0].Properties, "The response Value Properties member should not be null for currency 1!"); Assert.AreEqual(expectedCurrencies["code1"], response.Value[0].Properties.Code, $"Unexpected name for currency 1 ('{expectedCurrencies["code1"]}' != '{response.Value[0].Name}')"); Assert.AreEqual(expectedCurrencies["symbol1"], response.Value[0].Properties.Symbol, $"Unexpected symbol for currency 1 ('{expectedCurrencies["symbol1"]}' != '{response.Value[0].Properties.Symbol}')"); Assert.AreEqual(expectedCurrencies["name2"], response.Value[1].Name, $"Unexpected name for currency 2 ('{expectedCurrencies["name2"]}' != '{response.Value[1].Name}')"); Assert.IsNotNull(response.Value[1].Properties, "The response Value Properties member should not be null for currency 2!"); Assert.AreEqual(expectedCurrencies["code2"], response.Value[1].Properties.Code, $"Unexpected name for currency 2 ('{expectedCurrencies["code2"]}' != '{response.Value[1].Name}')"); Assert.AreEqual(expectedCurrencies["symbol2"], response.Value[1].Properties.Symbol, $"Unexpected symbol for currency 2 ('{expectedCurrencies["symbol2"]}' != '{response.Value[1].Properties.Symbol}')"); Assert.AreEqual(expectedCurrencies["name3"], response.Value[2].Name, $"Unexpected name for currency 3 ('{expectedCurrencies["name3"]}' != '{response.Value[2].Name}')"); Assert.IsNotNull(response.Value[2].Properties, "The response Value Properties member should not be null for currency 3!"); Assert.AreEqual(expectedCurrencies["code3"], response.Value[2].Properties.Code, $"Unexpected name for currency 3 ('{expectedCurrencies["code3"]}' != '{response.Value[2].Name}')"); Assert.AreEqual(expectedCurrencies["symbol3"], response.Value[2].Properties.Symbol, $"Unexpected symbol for currency 3 ('{expectedCurrencies["symbol3"]}' != '{response.Value[2].Properties.Symbol}')"); }
private object GetPowerAppsCdsDatabaseCurrenciesAsync(OperationRunner context) { context.Logger.LogInformation("Getting PowerApps Common Data Services database currencies..."); PowerAppsClient client = new PowerAppsClient(WizardContext.TokenProvider); client.SetLogger(context.Logger); return(client.GetCdsDatabaseCurrenciesAsync( DataModel.InstallationConfiguration.PowerApps.SelectedLocation).Result); }