From 9254f845f951d09c2fb8395a42a5e0c1905ab3c4 Mon Sep 17 00:00:00 2001 From: Tian Liao Date: Thu, 28 Nov 2024 15:33:26 +0800 Subject: [PATCH] resolve a comment --- src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp | 4 ++-- src/CalcViewModel/DataLoaders/CurrencyHttpClient.cpp | 4 ++-- src/CalcViewModel/DataLoaders/CurrencyHttpClient.h | 4 ++-- .../DataLoaders/CurrencyHttpClient.cpp | 4 ++-- src/CalculatorUnitTests/CurrencyConverterUnitTests.cpp | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp index 74bc03af..5e627287 100644 --- a/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp +++ b/src/CalcViewModel/DataLoaders/CurrencyDataLoader.cpp @@ -414,8 +414,8 @@ future 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; diff --git a/src/CalcViewModel/DataLoaders/CurrencyHttpClient.cpp b/src/CalcViewModel/DataLoaders/CurrencyHttpClient.cpp index d073b554..d53c525f 100644 --- a/src/CalcViewModel/DataLoaders/CurrencyHttpClient.cpp +++ b/src/CalcViewModel/DataLoaders/CurrencyHttpClient.cpp @@ -134,13 +134,13 @@ namespace CalculatorApp::ViewModel::DataLoaders m_responseLanguage = responseLanguage; } - MockAwaitable CurrencyHttpClient::GetCurrencyMetadata() const + MockAwaitable CurrencyHttpClient::GetCurrencyMetadataAsync() const { (void)m_responseLanguage; // to be used in production. return MockAwaitable{ ref new Platform::String(MockCurrencyStaticData) }; } - MockAwaitable CurrencyHttpClient::GetCurrencyRatios() const + MockAwaitable CurrencyHttpClient::GetCurrencyRatiosAsync() const { (void)m_sourceCurrencyCode; // to be used in production. return MockAwaitable{ ref new Platform::String(MockCurrencyConverterData) }; diff --git a/src/CalcViewModel/DataLoaders/CurrencyHttpClient.h b/src/CalcViewModel/DataLoaders/CurrencyHttpClient.h index 8a2cd10d..354dc685 100644 --- a/src/CalcViewModel/DataLoaders/CurrencyHttpClient.h +++ b/src/CalcViewModel/DataLoaders/CurrencyHttpClient.h @@ -33,8 +33,8 @@ namespace CalculatorApp::ViewModel::DataLoaders static bool ForceWebFailure; void Initialize(Platform::String ^ sourceCurrencyCode, Platform::String ^ responseLanguage); - MockAwaitable GetCurrencyMetadata() const; - MockAwaitable GetCurrencyRatios() const; + MockAwaitable GetCurrencyMetadataAsync() const; + MockAwaitable GetCurrencyRatiosAsync() const; private: Platform::String ^ m_sourceCurrencyCode; diff --git a/src/CalcViewModelCopyForUT/DataLoaders/CurrencyHttpClient.cpp b/src/CalcViewModelCopyForUT/DataLoaders/CurrencyHttpClient.cpp index ea4c3d34..c3be0e5d 100644 --- a/src/CalcViewModelCopyForUT/DataLoaders/CurrencyHttpClient.cpp +++ b/src/CalcViewModelCopyForUT/DataLoaders/CurrencyHttpClient.cpp @@ -21,7 +21,7 @@ namespace CalculatorApp::ViewModel::DataLoaders m_responseLanguage = responseLanguage; } - MockAwaitable CurrencyHttpClient::GetCurrencyMetadata() const + MockAwaitable CurrencyHttpClient::GetCurrencyMetadataAsync() const { if (ForceWebFailure) { @@ -31,7 +31,7 @@ namespace CalculatorApp::ViewModel::DataLoaders return MockAwaitable{ ref new Platform::String(MockCurrencyStaticData) }; } - MockAwaitable CurrencyHttpClient::GetCurrencyRatios() const + MockAwaitable CurrencyHttpClient::GetCurrencyRatiosAsync() const { if (ForceWebFailure) { diff --git a/src/CalculatorUnitTests/CurrencyConverterUnitTests.cpp b/src/CalculatorUnitTests/CurrencyConverterUnitTests.cpp index 4bbfc96f..cd9f7367 100644 --- a/src/CalculatorUnitTests/CurrencyConverterUnitTests.cpp +++ b/src/CalculatorUnitTests/CurrencyConverterUnitTests.cpp @@ -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" };