mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 13:53:11 -07:00
resolve a comment
This commit is contained in:
parent
1776695ce0
commit
9254f845f9
5 changed files with 13 additions and 13 deletions
|
@ -414,8 +414,8 @@ future<bool> CurrencyDataLoader::TryLoadDataFromWebAsync()
|
|||
co_return false;
|
||||
}
|
||||
|
||||
String ^ staticDataResponse = co_await m_client.GetCurrencyMetadata();
|
||||
String ^ allRatiosResponse = co_await m_client.GetCurrencyRatios();
|
||||
String ^ staticDataResponse = co_await m_client.GetCurrencyMetadataAsync();
|
||||
String ^ allRatiosResponse = co_await m_client.GetCurrencyRatiosAsync();
|
||||
if (staticDataResponse == nullptr || allRatiosResponse == nullptr)
|
||||
{
|
||||
co_return false;
|
||||
|
|
|
@ -134,13 +134,13 @@ namespace CalculatorApp::ViewModel::DataLoaders
|
|||
m_responseLanguage = responseLanguage;
|
||||
}
|
||||
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyMetadata() const
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyMetadataAsync() const
|
||||
{
|
||||
(void)m_responseLanguage; // to be used in production.
|
||||
return MockAwaitable<Platform::String ^>{ ref new Platform::String(MockCurrencyStaticData) };
|
||||
}
|
||||
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyRatios() const
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyRatiosAsync() const
|
||||
{
|
||||
(void)m_sourceCurrencyCode; // to be used in production.
|
||||
return MockAwaitable<Platform::String ^>{ ref new Platform::String(MockCurrencyConverterData) };
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace CalculatorApp::ViewModel::DataLoaders
|
|||
static bool ForceWebFailure;
|
||||
void Initialize(Platform::String ^ sourceCurrencyCode, Platform::String ^ responseLanguage);
|
||||
|
||||
MockAwaitable<Platform::String ^> GetCurrencyMetadata() const;
|
||||
MockAwaitable<Platform::String ^> GetCurrencyRatios() const;
|
||||
MockAwaitable<Platform::String ^> GetCurrencyMetadataAsync() const;
|
||||
MockAwaitable<Platform::String ^> GetCurrencyRatiosAsync() const;
|
||||
|
||||
private:
|
||||
Platform::String ^ m_sourceCurrencyCode;
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace CalculatorApp::ViewModel::DataLoaders
|
|||
m_responseLanguage = responseLanguage;
|
||||
}
|
||||
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyMetadata() const
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyMetadataAsync() const
|
||||
{
|
||||
if (ForceWebFailure)
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace CalculatorApp::ViewModel::DataLoaders
|
|||
return MockAwaitable<Platform::String ^>{ ref new Platform::String(MockCurrencyStaticData) };
|
||||
}
|
||||
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyRatios() const
|
||||
MockAwaitable<Platform::String ^> CurrencyHttpClient::GetCurrencyRatiosAsync() const
|
||||
{
|
||||
if (ForceWebFailure)
|
||||
{
|
||||
|
|
|
@ -160,8 +160,8 @@ namespace CalculatorUnitTests
|
|||
|
||||
VERIFY_IS_TRUE(DeleteCurrencyCacheFiles());
|
||||
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadata().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename, CurrencyHttpClient{}.GetCurrencyRatios().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadataAsync().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename, CurrencyHttpClient{}.GetCurrencyRatiosAsync().Value));
|
||||
}
|
||||
|
||||
TEST_CLASS(CurrencyConverterLoadTests){ public: TEST_METHOD_INITIALIZE(DeleteCacheFiles){ DeleteCurrencyCacheFiles();
|
||||
|
@ -207,7 +207,7 @@ TEST_METHOD(LoadFromCache_Fail_StaticDataFileDoesNotExist)
|
|||
InsertToLocalSettings(CurrencyDataLoaderConstants::CacheTimestampKey, now);
|
||||
|
||||
VERIFY_IS_TRUE(DeleteFileFromLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename, CurrencyHttpClient{}.GetCurrencyRatios().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename, CurrencyHttpClient{}.GetCurrencyRatiosAsync().Value));
|
||||
|
||||
CurrencyDataLoader loader{ L"en-US" };
|
||||
|
||||
|
@ -225,7 +225,7 @@ TEST_METHOD(LoadFromCache_Fail_AllRatiosDataFileDoesNotExist)
|
|||
DateTime now = Utils::GetUniversalSystemTime();
|
||||
InsertToLocalSettings(CurrencyDataLoaderConstants::CacheTimestampKey, now);
|
||||
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadata().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadataAsync().Value));
|
||||
VERIFY_IS_TRUE(DeleteFileFromLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename));
|
||||
|
||||
CurrencyDataLoader loader{ L"en-US" };
|
||||
|
@ -245,7 +245,7 @@ TEST_METHOD(LoadFromCache_Fail_ResponseLanguageChanged)
|
|||
// Tests always use en-US as response language. Insert a different lang-code to fail the test.
|
||||
InsertToLocalSettings(CurrencyDataLoaderConstants::CacheLangcodeKey, L"ar-SA");
|
||||
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadata().Value));
|
||||
VERIFY_IS_TRUE(WriteToFileInLocalCacheFolder(CurrencyDataLoaderConstants::StaticDataFilename, CurrencyHttpClient{}.GetCurrencyMetadataAsync().Value));
|
||||
VERIFY_IS_TRUE(DeleteFileFromLocalCacheFolder(CurrencyDataLoaderConstants::AllRatiosDataFilename));
|
||||
|
||||
CurrencyDataLoader loader{ L"en-US" };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue