diff --git a/src/CalcManager/CalculatorHistory.cpp b/src/CalcManager/CalculatorHistory.cpp index 384db076..467cd420 100644 --- a/src/CalcManager/CalculatorHistory.cpp +++ b/src/CalcManager/CalculatorHistory.cpp @@ -45,12 +45,7 @@ unsigned int CalculatorHistory::AddToHistory( spHistoryItem->historyItemVector.spTokens = tokens; spHistoryItem->historyItemVector.spCommands = commands; - - // to be changed when pszexp is back - wstring generatedExpression = GetGeneratedExpression(*tokens); - // Prefixing and suffixing the special Unicode markers to ensure that the expression - // in the history doesn't get broken for RTL languages - spHistoryItem->historyItemVector.expression = L'\u202d' + generatedExpression + L'\u202c'; + spHistoryItem->historyItemVector.expression = GetGeneratedExpression(*tokens); spHistoryItem->historyItemVector.result = wstring(result); return AddItem(spHistoryItem); } diff --git a/src/CalcViewModel/Common/Utils.h b/src/CalcViewModel/Common/Utils.h index 670274c4..1f24b23e 100644 --- a/src/CalcViewModel/Common/Utils.h +++ b/src/CalcViewModel/Common/Utils.h @@ -241,9 +241,6 @@ namespace Utils }; } - const wchar_t LRE = 0x202a; // Left-to-Right Embedding - const wchar_t PDF = 0x202c; // Pop Directional Formatting - const wchar_t LRO = 0x202d; // Left-to-Right Override // Regular DependencyProperty template diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 7c0b291d..63b72153 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -134,23 +134,14 @@ StandardCalculatorViewModel::StandardCalculatorViewModel() AreProgrammerRadixOperatorsEnabled = false; } -String ^ StandardCalculatorViewModel::LocalizeDisplayValue(_In_ wstring const& displayValue, _In_ bool isError) +String ^ StandardCalculatorViewModel::LocalizeDisplayValue(_In_ wstring const& displayValue) { wstring result(displayValue); - LocalizationSettings::GetInstance().LocalizeDisplayValue(&result); - - // WINBLUE: 440747 - In BiDi languages, error messages need to be wrapped in LRE/PDF - if (isError && m_isRtlLanguage) - { - result.insert(result.begin(), Utils::LRE); - result.push_back(Utils::PDF); - } - return ref new Platform::String(result.c_str()); } -String ^ StandardCalculatorViewModel::CalculateNarratorDisplayValue(_In_ wstring const& displayValue, _In_ String ^ localizedDisplayValue, _In_ bool isError) +String ^ StandardCalculatorViewModel::CalculateNarratorDisplayValue(_In_ wstring const& displayValue, _In_ String ^ localizedDisplayValue) { String ^ localizedValue = localizedDisplayValue; String ^ automationFormat = m_localizedCalculationResultAutomationFormat; @@ -159,7 +150,7 @@ String ^ StandardCalculatorViewModel::CalculateNarratorDisplayValue(_In_ wstring if (Utils::IsLastCharacterTarget(displayValue, m_decimalSeparator)) { // remove the decimal separator, to avoid a long pause between words - localizedValue = LocalizeDisplayValue(displayValue.substr(0, displayValue.length() - 1), isError); + localizedValue = LocalizeDisplayValue(displayValue.substr(0, displayValue.length() - 1)); // Use a format which has a word in the decimal separator's place // "The Display is 10 point" @@ -195,11 +186,11 @@ String ^ StandardCalculatorViewModel::GetNarratorStringReadRawNumbers(_In_ Strin void StandardCalculatorViewModel::SetPrimaryDisplay(_In_ String ^ displayStringValue, _In_ bool isError) { - String ^ localizedDisplayStringValue = LocalizeDisplayValue(displayStringValue->Data(), isError); + String ^ localizedDisplayStringValue = LocalizeDisplayValue(displayStringValue->Data()); // Set this variable before the DisplayValue is modified, Otherwise the DisplayValue will // not match what the narrator is saying - m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue->Data(), localizedDisplayStringValue, isError); + m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue->Data(), localizedDisplayStringValue); AreAlwaysOnTopResultsUpdated = false; if (DisplayValue != localizedDisplayStringValue) @@ -418,7 +409,7 @@ void StandardCalculatorViewModel::SetMemorizedNumbers(const vector& new MemoryItemViewModel ^ memorySlot = ref new MemoryItemViewModel(this); memorySlot->Position = 0; localizer.LocalizeDisplayValue(&stringValue); - memorySlot->Value = Utils::LRO + ref new String(stringValue.c_str()) + Utils::PDF; + memorySlot->Value = ref new String(stringValue.c_str()); MemorizedNumbers->InsertAt(0, memorySlot); IsMemoryEmpty = IsAlwaysOnTop; @@ -440,7 +431,7 @@ void StandardCalculatorViewModel::SetMemorizedNumbers(const vector& new // If the value is different, update the value if (MemorizedNumbers->GetAt(i)->Value != StringReference(newStringValue.c_str())) { - MemorizedNumbers->GetAt(i)->Value = Utils::LRO + ref new String(newStringValue.c_str()) + Utils::PDF; + MemorizedNumbers->GetAt(i)->Value = ref new String(newStringValue.c_str()); } } } @@ -1576,10 +1567,10 @@ void StandardCalculatorViewModel::UpdateProgrammerPanelDisplay() localizer.LocalizeDisplayValue(&octalDisplayString); localizer.LocalizeDisplayValue(&binaryDisplayString); - HexDisplayValue = Utils::LRO + ref new Platform::String(hexDisplayString.c_str()) + Utils::PDF; - DecimalDisplayValue = Utils::LRO + ref new Platform::String(decimalDisplayString.c_str()) + Utils::PDF; - OctalDisplayValue = Utils::LRO + ref new Platform::String(octalDisplayString.c_str()) + Utils::PDF; - BinaryDisplayValue = Utils::LRO + ref new Platform::String(binaryDisplayString.c_str()) + Utils::PDF; + HexDisplayValue = ref new Platform::String(hexDisplayString.c_str()); + DecimalDisplayValue = ref new Platform::String(decimalDisplayString.c_str()); + OctalDisplayValue = ref new Platform::String(octalDisplayString.c_str()); + BinaryDisplayValue = ref new Platform::String(binaryDisplayString.c_str()); HexDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedHexaDecimalAutomationFormat, GetNarratorStringReadRawNumbers(HexDisplayValue)); DecDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedDecimalAutomationFormat, DecimalDisplayValue); OctDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedOctalAutomationFormat, GetNarratorStringReadRawNumbers(OctalDisplayValue)); diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index a5095791..d97a450b 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -341,9 +341,9 @@ namespace CalculatorApp Platform::String ^ m_selectedExpressionLastData; Common::DisplayExpressionToken ^ m_selectedExpressionToken; - Platform::String ^ LocalizeDisplayValue(_In_ std::wstring const& displayValue, _In_ bool isError); + Platform::String ^ LocalizeDisplayValue(_In_ std::wstring const& displayValue); Platform::String - ^ CalculateNarratorDisplayValue(_In_ std::wstring const& displayValue, _In_ Platform::String ^ localizedDisplayValue, _In_ bool isError); + ^ CalculateNarratorDisplayValue(_In_ std::wstring const& displayValue, _In_ Platform::String ^ localizedDisplayValue); CalculatorApp::Common::Automation::NarratorAnnouncement ^ GetDisplayUpdatedNarratorAnnouncement(); Platform::String ^ GetCalculatorExpressionAutomationName(); Platform::String ^ GetNarratorStringReadRawNumbers(_In_ Platform::String ^ localizedDisplayValue); diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index 3b46d9ab..c2ad77e4 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -381,7 +381,6 @@ String ^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& st } result = L"-" + result; } - result = Utils::LRE + result + Utils::PDF; return result; } diff --git a/src/Calculator/App.xaml b/src/Calculator/App.xaml index 7082c752..46739c13 100644 --- a/src/Calculator/App.xaml +++ b/src/Calculator/App.xaml @@ -577,7 +577,9 @@ - + diff --git a/src/Calculator/Controls/CalculationResult.cpp b/src/Calculator/Controls/CalculationResult.cpp index 1b15333a..c2542f10 100644 --- a/src/Calculator/Controls/CalculationResult.cpp +++ b/src/Calculator/Controls/CalculationResult.cpp @@ -215,7 +215,7 @@ void CalculationResult::UpdateTextState() auto containerSize = m_textContainer->ActualWidth; String ^ oldText = m_textBlock->Text; - String ^ newText = Utils::LRO + DisplayValue + Utils::PDF; + String ^ newText = DisplayValue; // Initiate the scaling operation // UpdateLayout will keep calling us until we make it through the below 2 if-statements diff --git a/src/Calculator/Views/Calculator.xaml b/src/Calculator/Views/Calculator.xaml index aa2e7a9f..b189b4f1 100644 --- a/src/Calculator/Views/Calculator.xaml +++ b/src/Calculator/Views/Calculator.xaml @@ -37,7 +37,9 @@ - + @@ -96,7 +98,9 @@ - + diff --git a/src/Calculator/Views/CalculatorProgrammerOperators.xaml b/src/Calculator/Views/CalculatorProgrammerOperators.xaml index 008d219a..4fe2fcd1 100644 --- a/src/Calculator/Views/CalculatorProgrammerOperators.xaml +++ b/src/Calculator/Views/CalculatorProgrammerOperators.xaml @@ -163,7 +163,8 @@ + AutomationProperties.HeadingLevel="Level1" + FlowDirection="LeftToRight"> diff --git a/src/Calculator/Views/HistoryList.xaml b/src/Calculator/Views/HistoryList.xaml index eff64adf..89cb2750 100644 --- a/src/Calculator/Views/HistoryList.xaml +++ b/src/Calculator/Views/HistoryList.xaml @@ -2,10 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:automation="using:CalculatorApp.Common.Automation" - xmlns:controls="using:CalculatorApp.Controls" xmlns:converters="using:CalculatorApp.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="using:CalculatorApp" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:model="using:CalculatorApp.ViewModel" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" diff --git a/src/Calculator/Views/MemoryListItem.xaml b/src/Calculator/Views/MemoryListItem.xaml index edba1e62..1b59f886 100644 --- a/src/Calculator/Views/MemoryListItem.xaml +++ b/src/Calculator/Views/MemoryListItem.xaml @@ -1,13 +1,8 @@ - diff --git a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters index 90ec1121..292d5195 100644 --- a/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters +++ b/src/CalculatorUnitTests/CalculatorUnitTests.vcxproj.filters @@ -30,7 +30,6 @@ - diff --git a/src/CalculatorUnitTests/Helper.cpp b/src/CalculatorUnitTests/Helper.cpp deleted file mode 100644 index 76361855..00000000 --- a/src/CalculatorUnitTests/Helper.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "pch.h" -#include "Helpers.h" -using namespace Platform; -using namespace std; - -String ^ GetStringValue(String ^ input) { - // Remove first and last " characters - if (input->Length() >= 3) - { - wstring out(input->Begin() + 1, input->End() - 1); - return ref new String(out.c_str()); - } - return input; -} diff --git a/src/CalculatorUnitTests/Helpers.h b/src/CalculatorUnitTests/Helpers.h index 9b364cef..251574c5 100644 --- a/src/CalculatorUnitTests/Helpers.h +++ b/src/CalculatorUnitTests/Helpers.h @@ -22,9 +22,6 @@ namespace CalculatorUnitTests namespace UtfUtils { - constexpr wchar_t LRE = 0x202a; // Left-to-Right Embedding - constexpr wchar_t PDF = 0x202c; // Pop Directional Formatting - constexpr wchar_t LRO = 0x202d; // Left-to-Right Override constexpr wchar_t MUL = 0x00d7; // Multiplication Symbol } } @@ -108,5 +105,3 @@ void VERIFY_VECTORS_ARE_EQUAL(Windows::Foundation::Collections::IVector ^ vec VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i), __VA_ARGS__); } }; - -Platform::String ^ GetStringValue(Platform::String ^ input); diff --git a/src/CalculatorUnitTests/HistoryTests.cpp b/src/CalculatorUnitTests/HistoryTests.cpp index 71b58ce7..f2eb04b6 100644 --- a/src/CalculatorUnitTests/HistoryTests.cpp +++ b/src/CalculatorUnitTests/HistoryTests.cpp @@ -80,7 +80,7 @@ namespace CalculatorFunctionalTests m_standardViewModel->SendCommandToCalcManager(static_cast(Command::CommandEQU)); int sizeAfterItemAdd = m_historyViewModel->ItemSize; auto historyItem = static_cast(m_historyViewModel->Items->GetAt(0)); - String ^ expression = UtfUtils::LRO + L"1 + 8 =" + UtfUtils::PDF; + String ^ expression = L"1 + 8 ="; VERIFY_ARE_EQUAL(initialSize + 1, sizeAfterItemAdd); VERIFY_ARE_EQUAL(historyItem->Expression, expression); VERIFY_ARE_EQUAL(historyItem->Result, L"9"); @@ -102,7 +102,7 @@ namespace CalculatorFunctionalTests m_standardViewModel->SendCommandToCalcManager(static_cast(Command::CommandEQU)); } VERIFY_ARE_EQUAL((size_t)m_historyViewModel->ItemSize, m_historyViewModel->GetMaxItemSize()); - String ^ expression = UtfUtils::LRO + L"1 + 1 =" + UtfUtils::PDF; + String ^ expression = L"1 + 1 ="; int output = 2; String ^ result = output.ToString(); auto historyItem = static_cast(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1)); @@ -112,7 +112,7 @@ namespace CalculatorFunctionalTests m_standardViewModel->SendCommandToCalcManager(static_cast(Command::CommandADD)); m_standardViewModel->SendCommandToCalcManager(static_cast(Command::Command5)); m_standardViewModel->SendCommandToCalcManager(static_cast(Command::CommandEQU)); - expression = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF; + expression = L"1 + 2 ="; output = 3; result = output.ToString(); historyItem = static_cast(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1)); @@ -154,7 +154,6 @@ namespace CalculatorFunctionalTests for (int i = 0; i < scientificItems; i++) { wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" ="; - expr = UtfUtils::LRO + expr + UtfUtils::PDF; int output = 1 + i; String ^ result = output.ToString(); auto historyItem = static_cast(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i)); @@ -168,7 +167,6 @@ namespace CalculatorFunctionalTests for (int i = 0; i < standardItems; i++) { wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" ="; - expr = UtfUtils::LRO + expr + UtfUtils::PDF; int output = 1 + i; String ^ result = output.ToString(); auto historyItem = static_cast(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i)); @@ -238,8 +236,6 @@ namespace CalculatorFunctionalTests m_historyViewModel->ReloadHistory(ViewMode::Scientific); m_standardViewModel->SendCommandToCalcManager(static_cast(Command::ModeScientific)); wstring expr = L"1 + 8 ="; - // add double quotes around the expression - expr = UtfUtils::LRO + expr + UtfUtils::PDF; String ^ result = StringReference(L"9"); int itemsAfterSaveAndReload = m_historyViewModel->ItemSize; @@ -275,7 +271,6 @@ namespace CalculatorFunctionalTests String ^ expression = m_uiResourceLoader->GetString(commandResource.ToString()); expression += L"( 1 ) ="; wstring expr = wstring(expression->Data()); - expr = UtfUtils::LRO + expr + UtfUtils::PDF; VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str())); commandResource++; itemIndex++; @@ -309,7 +304,6 @@ namespace CalculatorFunctionalTests expression += m_uiResourceLoader->GetString(L"79"); expression += L"( 1 ) ="; wstring expr = wstring(expression->Data()); - expr = UtfUtils::LRO + expr + UtfUtils::PDF; VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str())); Cleanup(); @@ -406,13 +400,13 @@ namespace CalculatorFunctionalTests m_standardViewModel->SendCommandToCalcManager(static_cast(Command::Command7)); m_standardViewModel->SendCommandToCalcManager(static_cast(Command::CommandEQU)); String ^ expression = L"HexaDecimal" + L" 8"; - String ^ result = L"HexaDecimal " + GetStringValue(m_standardViewModel->HexDisplayValue); + String ^ result = L"HexaDecimal " + m_standardViewModel->HexDisplayValue; VERIFY_ARE_EQUAL(expression, result); expression = StringReference(L"Octal 10"); - result = L"Octal " + GetStringValue(m_standardViewModel->OctalDisplayValue); + result = L"Octal " + m_standardViewModel->OctalDisplayValue; VERIFY_ARE_EQUAL(expression, result); expression = StringReference(L"Binary 1000"); - result = L"Binary " + GetStringValue(m_standardViewModel->BinaryDisplayValue); + result = L"Binary " + m_standardViewModel->BinaryDisplayValue; VERIFY_ARE_EQUAL(expression, result); Cleanup(); } diff --git a/src/CalculatorUnitTests/MultiWindowUnitTests.cpp b/src/CalculatorUnitTests/MultiWindowUnitTests.cpp index 1aa861a1..a9810d9c 100644 --- a/src/CalculatorUnitTests/MultiWindowUnitTests.cpp +++ b/src/CalculatorUnitTests/MultiWindowUnitTests.cpp @@ -132,14 +132,14 @@ TEST_METHOD(MultipleModesCalculationTest) { NumbersAndOperatorsEnum::F, L"F", L"" }, { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(viewModels[2], programmerModeTestItems, false); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->HexDisplayValue), StringReference(L"F")); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->DecimalDisplayValue), StringReference(L"15")); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->OctalDisplayValue), StringReference(L"17")); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->BinaryDisplayValue), StringReference(L"1111")); + VERIFY_ARE_EQUAL(viewModels[2]->HexDisplayValue, StringReference(L"F")); + VERIFY_ARE_EQUAL(viewModels[2]->DecimalDisplayValue, StringReference(L"15")); + VERIFY_ARE_EQUAL(viewModels[2]->OctalDisplayValue, StringReference(L"17")); + VERIFY_ARE_EQUAL(viewModels[2]->BinaryDisplayValue, StringReference(L"1111")); // Assert that Standard and Scientific mode Display Values are unchanged - VERIFY_ARE_EQUAL(GetStringValue(viewModels[0]->DisplayValue), StringReference(L"3")); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[1]->DisplayValue), StringReference(L"7")); + VERIFY_ARE_EQUAL(viewModels[0]->DisplayValue, StringReference(L"3")); + VERIFY_ARE_EQUAL(viewModels[1]->DisplayValue, StringReference(L"7")); } // Perform calculations on 2 instances of Calculator in Standard Mode and verify that they work independently @@ -174,7 +174,7 @@ TEST_METHOD(MultipleStandardModeCalculationTest) ValidateViewModelByCommands(standardViewModel2, standardModeTestItems2, true); // Assert that the Display Value of 1st instance is unchanged - VERIFY_ARE_EQUAL(GetStringValue(standardViewModel1->DisplayValue), StringReference(L"1")); + VERIFY_ARE_EQUAL(standardViewModel1->DisplayValue, StringReference(L"1")); } // Perform calculations on 2 instances of Calculator in Scientific Mode and verify that they work independently @@ -209,7 +209,7 @@ TEST_METHOD(MultipleScientificModeCalculationTest) ValidateViewModelByCommands(scientificViewModel2, scientificModeTestItems2, true); // Assert that the Display Value of 1st instance is unchanged - VERIFY_ARE_EQUAL(GetStringValue(scientificViewModel1->DisplayValue), StringReference(L"1")); + VERIFY_ARE_EQUAL(scientificViewModel1->DisplayValue, StringReference(L"1")); } // Perform calculations on 2 instances of Calculator in Scientific Mode @@ -274,10 +274,10 @@ TEST_METHOD(MultipleProgrammerModeCalculationTest) { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"F")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"15")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"17")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111")); + VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"F")); + VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"15")); + VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"17")); + VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111")); // Radix Type: Octal, Expression: 7 TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::OctButton, L"0", L"" }, @@ -285,17 +285,17 @@ TEST_METHOD(MultipleProgrammerModeCalculationTest) { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->HexDisplayValue), StringReference(L"7")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->DecimalDisplayValue), StringReference(L"7")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->OctalDisplayValue), StringReference(L"7")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->BinaryDisplayValue), StringReference(L"0111")); + VERIFY_ARE_EQUAL(programmerViewModel2->HexDisplayValue, StringReference(L"7")); + VERIFY_ARE_EQUAL(programmerViewModel2->DecimalDisplayValue, StringReference(L"7")); + VERIFY_ARE_EQUAL(programmerViewModel2->OctalDisplayValue, StringReference(L"7")); + VERIFY_ARE_EQUAL(programmerViewModel2->BinaryDisplayValue, StringReference(L"0111")); // Assert that displayed values of 1st instance are unchanged - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DisplayValue), StringReference(L"F")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"F")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"15")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"17")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111")); + VERIFY_ARE_EQUAL(programmerViewModel1->DisplayValue, StringReference(L"F")); + VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"F")); + VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"15")); + VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"17")); + VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111")); } // Perform calculations on 2 instances of Calculator in Programmer Mode @@ -335,10 +335,10 @@ TEST_METHOD(MultipleProgrammerModeWithDifferentSettingsTest) { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"FF")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"-1")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"377")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111 1111")); + VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"FF")); + VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"-1")); + VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"377")); + VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111 1111")); TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::Seven, L"7", L"" }, { NumbersAndOperatorsEnum::Seven, L"77", L"" }, @@ -350,10 +350,10 @@ TEST_METHOD(MultipleProgrammerModeWithDifferentSettingsTest) { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->HexDisplayValue), StringReference(L"7FFF")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->DecimalDisplayValue), StringReference(L"32,767")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->OctalDisplayValue), StringReference(L"77 777")); - VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->BinaryDisplayValue), StringReference(L"0111 1111 1111 1111")); + VERIFY_ARE_EQUAL(programmerViewModel2->HexDisplayValue, StringReference(L"7FFF")); + VERIFY_ARE_EQUAL(programmerViewModel2->DecimalDisplayValue, StringReference(L"32,767")); + VERIFY_ARE_EQUAL(programmerViewModel2->OctalDisplayValue, StringReference(L"77 777")); + VERIFY_ARE_EQUAL(programmerViewModel2->BinaryDisplayValue, StringReference(L"0111 1111 1111 1111")); } // Perform calculations on 2 separate instances of Calculator and verify that their History list items are maintained separately @@ -392,8 +392,8 @@ TEST_METHOD(MultipleModesHistoryAddItemTest) // Assert for the history list items of 1st instance VERIFY_IS_TRUE(1 == viewModels[0]->HistoryVM->ItemSize); - auto item1 = static_cast(viewModels[0]->HistoryVM->Items->GetAt(0)); - String ^ expression1 = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF; + auto item1 = static_cast(viewModels[0]->HistoryVM->Items->GetAt(0)); + String ^ expression1 = L"1 + 2 ="; String ^ result1 = L"3"; VERIFY_ARE_EQUAL(expression1, item1->Expression); @@ -402,8 +402,8 @@ TEST_METHOD(MultipleModesHistoryAddItemTest) // Assert for the history list items of 2nd instance VERIFY_IS_TRUE(1 == viewModels[1]->HistoryVM->ItemSize); - auto item2 = static_cast(viewModels[1]->HistoryVM->Items->GetAt(0)); - String ^ expression2 = UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + UtfUtils::PDF; + auto item2 = static_cast(viewModels[1]->HistoryVM->Items->GetAt(0)); + String ^ expression2 = L"1 + 2 " + UtfUtils::MUL + L" 3 ="; String ^ result2 = L"7"; VERIFY_ARE_EQUAL(expression2, item2->Expression); @@ -451,7 +451,7 @@ TEST_METHOD(MultipleStandardModesHistoryAddItemTest) ValidateViewModelByCommands(viewModels[i], standardModeTestItems[i], true); } - String ^ expression[] = { UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF, UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + UtfUtils::PDF }; + String ^ expression[] = { L"1 + 2 =", L"1 + 2 " + UtfUtils::MUL + L" 3 =" }; String ^ result[] = { L"3", L"7" }; // Assert for the history list items of the instances @@ -507,7 +507,7 @@ TEST_METHOD(MultipleScientificModesHistoryAddItemTest) ValidateViewModelByCommands(viewModels[i], standardModeTestItems[i], true); } - String ^ expression[] = { UtfUtils::LRO + L"1 + 2 =" + Utils::PDF, UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + Utils::PDF }; + String ^ expression[] = { L"1 + 2 =", L"1 + 2 " + UtfUtils::MUL + L" 3 =" }; String ^ result[] = { L"3", L"9" }; // Assert for the history list items of the instances @@ -515,7 +515,7 @@ TEST_METHOD(MultipleScientificModesHistoryAddItemTest) { VERIFY_IS_TRUE(1 == viewModels[i]->HistoryVM->ItemSize); - auto item = static_cast(viewModels[i]->HistoryVM->Items->GetAt(0)); + auto item = static_cast(viewModels[i]->HistoryVM->Items->GetAt(0)); VERIFY_ARE_EQUAL(expression[i], item->Expression); VERIFY_ARE_EQUAL(result[i], item->Result); @@ -567,7 +567,7 @@ TEST_METHOD(MultipleModesMemoryAddItemTest) viewModels[i]->ButtonPressed->Execute(NumbersAndOperatorsEnum::Memory); } - String ^ expectedMemoryValues[] = { UtfUtils::LRO + L"3" + UtfUtils::PDF, UtfUtils::LRO + L"7" + UtfUtils::PDF, UtfUtils::LRO + L"F" + UtfUtils::PDF }; + String ^ expectedMemoryValues[] = { L"3", L"7", L"F" }; // Validate that only one item is present in the memory // Also assert for their value @@ -781,7 +781,7 @@ TEST_METHOD(MultipleConverterModeCalculationTest) auto expectedValue1 = (i + 1).ToString(); auto actualValue1 = viewModels[i]->Value1; - VERIFY_ARE_EQUAL(expectedValue1, GetStringValue(actualValue1)); + VERIFY_ARE_EQUAL(expectedValue1, actualValue1); std::wstring unit1Name = viewModels[i]->Unit1->Name->Data(); std::wstring unit2Name = viewModels[i]->Unit2->Name->Data(); @@ -789,7 +789,7 @@ TEST_METHOD(MultipleConverterModeCalculationTest) auto resKey = String::Concat(ref new String((unit1Name + L"-" + unit2Name + L"-").c_str()), expectedValue1); String ^ expectedResult = resLoader->GetString(resKey); - String ^ actualResult = GetStringValue(viewModels[i]->Value2); + String ^ actualResult = viewModels[i]->Value2; VERIFY_ARE_EQUAL(expectedResult, actualResult); } @@ -860,11 +860,11 @@ TEST_METHOD(TestStandardUnitConverterAndDateViewModels) unitConverterViewModel->ButtonPressed->Execute(NumbersAndOperatorsEnum::Two); // Validate the Result - VERIFY_ARE_EQUAL(StringReference(L"2"), GetStringValue(unitConverterViewModel->Value1)); - VERIFY_ARE_EQUAL(StringReference(L"0.002"), GetStringValue(unitConverterViewModel->Value2)); + VERIFY_ARE_EQUAL(StringReference(L"2"), unitConverterViewModel->Value1); + VERIFY_ARE_EQUAL(StringReference(L"0.002"), unitConverterViewModel->Value2); // Assert that the Display Value of Standard Calc instance is unchanged - VERIFY_ARE_EQUAL(GetStringValue(standardViewModel->DisplayValue), StringReference(L"1")); + VERIFY_ARE_EQUAL(standardViewModel->DisplayValue, StringReference(L"1")); // Again perform calculations on Standard Calc instance and validate that the Converter remains unaffected @@ -875,14 +875,14 @@ TEST_METHOD(TestStandardUnitConverterAndDateViewModels) { NumbersAndOperatorsEnum::Equals, L"3", L"" }, { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(standardViewModel, standardModeTestItems2, true); - VERIFY_ARE_EQUAL(StringReference(L"3"), GetStringValue(standardViewModel->DisplayValue)); + VERIFY_ARE_EQUAL(StringReference(L"3"), standardViewModel->DisplayValue); // Validate the Date Calculator VERIFY_ARE_EQUAL(DateUtils::GetLongDate(endDate), dateCalcViewModel->StrDateResult); // Validate the Unit Converter - VERIFY_ARE_EQUAL(StringReference(L"2"), GetStringValue(unitConverterViewModel->Value1)); - VERIFY_ARE_EQUAL(StringReference(L"0.002"), GetStringValue(unitConverterViewModel->Value2)); + VERIFY_ARE_EQUAL(StringReference(L"2"), unitConverterViewModel->Value1); + VERIFY_ARE_EQUAL(StringReference(L"0.002"), unitConverterViewModel->Value2); } // Change the radix in programmer mode and check that other modes are not affected @@ -902,7 +902,7 @@ TEST_METHOD(MultipleModesWithChangeInProgrammerRadix) { NumbersAndOperatorsEnum::F, L"F", L"" }, { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(viewModels[1], programmerModeTestItems, false /*doReset*/); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[1]->HexDisplayValue), StringReference(L"F")); + VERIFY_ARE_EQUAL(viewModels[1]->HexDisplayValue, StringReference(L"F")); // Standard Mode: Expression 10+2= // Radix should be decimal, not hex @@ -930,7 +930,7 @@ TEST_METHOD(MultipleModesWithChangeInProgrammerRadix) { NumbersAndOperatorsEnum::Equals, L"B", L"" }, { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(viewModels[1], programmerModeTestItemsNew, true /*doReset*/); - VERIFY_ARE_EQUAL(GetStringValue(viewModels[1]->HexDisplayValue), StringReference(L"B")); + VERIFY_ARE_EQUAL(viewModels[1]->HexDisplayValue, StringReference(L"B")); } } ; diff --git a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp index 58711635..664d2b8b 100644 --- a/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp +++ b/src/CalculatorUnitTests/StandardViewModelUnitTests.cpp @@ -495,10 +495,10 @@ namespace CalculatorUnitTests { NumbersAndOperatorsEnum::F, L"F", L"" }, { NumbersAndOperatorsEnum::None, L"", L"" } }; ValidateViewModelByCommands(m_viewModel, items, false); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"F")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111")); + VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"F")); + VERIFY_ARE_EQUAL(m_viewModel->DecimalDisplayValue, StringReference(L"15")); + VERIFY_ARE_EQUAL(m_viewModel->OctalDisplayValue, StringReference(L"17")); + VERIFY_ARE_EQUAL(m_viewModel->BinaryDisplayValue, StringReference(L"1111")); auto val = ref new Platform::Collections::Vector(64, false); val->SetAt(0, true); val->SetAt(1, true); @@ -548,10 +548,10 @@ namespace CalculatorUnitTests { NumbersAndOperatorsEnum::None, L"1", L"" }, }; ValidateViewModelByCommands(m_viewModel, items, true); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"75B CD15")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101")); + VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"75B CD15")); + VERIFY_ARE_EQUAL(m_viewModel->DecimalDisplayValue, StringReference(L"123,456,789")); + VERIFY_ARE_EQUAL(m_viewModel->OctalDisplayValue, StringReference(L"726 746 425")); + VERIFY_ARE_EQUAL(m_viewModel->BinaryDisplayValue, StringReference(L"0111 0101 1011 1100 1101 0001 0101")); auto val = ref new Platform::Collections::Vector(64, false); val->SetAt(0, true); val->SetAt(2, true); @@ -582,11 +582,11 @@ namespace CalculatorUnitTests { NumbersAndOperatorsEnum::Not, L"-2", L"~(1)" }, { NumbersAndOperatorsEnum::None, L"N/A", L"N/A" } }; ValidateViewModelByCommands(m_viewModel, items, false); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"FFFF FFFF FFFF FFFE")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"-2")); - VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"1 777 777 777 777 777 777 776")); + VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"FFFF FFFF FFFF FFFE")); + VERIFY_ARE_EQUAL(m_viewModel->DecimalDisplayValue, StringReference(L"-2")); + VERIFY_ARE_EQUAL(m_viewModel->OctalDisplayValue, StringReference(L"1 777 777 777 777 777 777 776")); VERIFY_ARE_EQUAL( - GetStringValue(m_viewModel->BinaryDisplayValue), + m_viewModel->BinaryDisplayValue, StringReference(L"1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1110")); VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2")); auto val = ref new Platform::Collections::Vector(64, true); @@ -776,13 +776,13 @@ namespace CalculatorUnitTests m_viewModel->OnMemoryItemPressed(ref new Platform::Box(0)); VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), m_viewModel->DisplayValue); MemoryItemViewModel ^ memorySlotStandard = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), GetStringValue(memorySlotStandard->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), memorySlotStandard->Value); ChangeMode(m_viewModel, 1 /*scientific*/); MemoryItemViewModel ^ memorySlotScientific = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), GetStringValue(memorySlotScientific->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), memorySlotScientific->Value); ChangeMode(m_viewModel, 2 /*Programmer*/); MemoryItemViewModel ^ memorySlotProgrammer = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), GetStringValue(memorySlotProgrammer->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), memorySlotProgrammer->Value); } // When decimal number is saved in memory @@ -800,13 +800,13 @@ namespace CalculatorUnitTests m_viewModel->OnMemoryItemPressed(ref new Platform::Box(0)); VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), m_viewModel->DisplayValue); MemoryItemViewModel ^ memorySlotStandard = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), GetStringValue(memorySlotStandard->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), memorySlotStandard->Value); ChangeMode(m_viewModel, 1 /*Scientific*/); MemoryItemViewModel ^ memorySlotScientific = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), GetStringValue(memorySlotScientific->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), memorySlotScientific->Value); ChangeMode(m_viewModel, 2 /*Programmer*/); MemoryItemViewModel ^ memorySlotProgrammer = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001"), GetStringValue(memorySlotProgrammer->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001"), memorySlotProgrammer->Value); } // When negative decimal number is saved in memory @@ -865,7 +865,7 @@ namespace CalculatorUnitTests m_viewModel->OnMemoryItemPressed(ref new Box(0)); VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), m_viewModel->DisplayValue); MemoryItemViewModel ^ memorySlot = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), GetStringValue(memorySlot->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), memorySlot->Value); } TEST_METHOD(OnMemorySavedInHexRadixAndRadixChanges) @@ -881,13 +881,13 @@ namespace CalculatorUnitTests m_viewModel->OnMemoryButtonPressed(); m_viewModel->SwitchProgrammerModeBase(NumberBase::OctBase); MemoryItemViewModel ^ memorySlotOct = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"377"), GetStringValue(memorySlotOct->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"377"), memorySlotOct->Value); m_viewModel->SwitchProgrammerModeBase(NumberBase::DecBase); MemoryItemViewModel ^ memorySlotDec = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), GetStringValue(memorySlotDec->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), memorySlotDec->Value); m_viewModel->SwitchProgrammerModeBase(NumberBase::BinBase); MemoryItemViewModel ^ memorySlotBin = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"1111 1111"), GetStringValue(memorySlotBin->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"1111 1111"), memorySlotBin->Value); } // When memory button is pressed more than max number of slots allowed, @@ -966,7 +966,7 @@ namespace CalculatorUnitTests m_viewModel->OnMemoryItemPressed(1); m_viewModel->OnMemoryAdd(ref new Platform::Box(0)); MemoryItemViewModel ^ memorySlot = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); - VERIFY_ARE_EQUAL(Platform::StringReference(L"3,003"), GetStringValue(memorySlot->Value)); + VERIFY_ARE_EQUAL(Platform::StringReference(L"3,003"), memorySlot->Value); } // Verify that raw, unformatted numbers are provided correctly diff --git a/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.cpp b/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.cpp index 09bb549a..11fc09f9 100644 --- a/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.cpp +++ b/src/CalculatorUnitTests/UnitConverterViewModelUnitTests.cpp @@ -27,13 +27,6 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; namespace CalculatorUnitTests { - String^ AddUnicodeLTRMarkers(wstring str) - { - str.insert(str.begin(), L'\u202a'); - str.push_back(L'\u202c'); - return ref new String(str.c_str()); - } - TEST_CLASS(CategoryViewModelTests) { public: @@ -298,7 +291,7 @@ for (unsigned int k = 0; k < categoryList->Size; k++) wstring expResult = expectedResult->Data(); double expectedConversion = GetDoubleFromWstring(expResult); - double actualConversion = GetDoubleFromWstring(GetStringValue(vm->Value1)->Data()); + double actualConversion = GetDoubleFromWstring(vm->Value1->Data()); double diff = abs(expectedConversion - actualConversion); // Assert for diff less than epsilonth fraction of expected conversion result @@ -422,10 +415,9 @@ TEST_METHOD(TestDisplayCallbackUpdatesDisplayValues) { shared_ptr mock = make_shared(); VM::UnitConverterViewModel vm(mock); - const WCHAR *vFrom = L"1234", *vTo = L"56.78"; - vm.UpdateDisplay(vFrom, vTo); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"1,234")); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(vTo)); + vm.UpdateDisplay(L"1234", L"56.78"); + VERIFY_IS_TRUE(vm.Value1 == L"1,234"); + VERIFY_IS_TRUE(vm.Value2 == L"56.78"); } // Test that the calculator button command correctly fires @@ -570,10 +562,9 @@ TEST_METHOD(TestDisplayValueUpdatesAfterSwitchingActiveUpdateTheRightDisplay) const WCHAR *vFrom = L"1", *vTo = L"234"; vm.UpdateDisplay(vFrom, vTo); vm.Value2Active = true; - const WCHAR *newvFrom = L"3", *newvTo = L"57"; - vm.UpdateDisplay(newvFrom, newvTo); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvFrom)); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvTo)); + vm.UpdateDisplay(L"3", L"57"); + VERIFY_IS_TRUE(vm.Value2 == L"3"); + VERIFY_IS_TRUE(vm.Value1 == L"57"); } // Tests that when we switch the active field and get change units, @@ -637,10 +628,9 @@ TEST_METHOD(TestCategoryChangeAfterSwitchingActiveUpdatesDisplayCorrectly) VERIFY_IS_TRUE(UNIT9 == mock->m_curFrom); VERIFY_IS_TRUE(UNIT7 == mock->m_curTo); VERIFY_ARE_EQUAL((UINT)1, mock->m_switchActiveCallCount); - const wchar_t *newvFrom = L"5", *newvTo = L"7"; - vm.UpdateDisplay(newvFrom, newvTo); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvFrom)); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvTo)); + vm.UpdateDisplay(L"5", L"7"); + VERIFY_IS_TRUE(vm.Value2 == L"5"); + VERIFY_IS_TRUE(vm.Value1 == L"7"); } // Repeat above active switch tests but with a second switch to ensure @@ -682,10 +672,9 @@ TEST_METHOD(TestDisplayValueUpdatesAfterSwitchingActiveTwiceUpdateTheRightDispla vm.UpdateDisplay(vFrom, vTo); vm.Value2Active = true; vm.Value1Active = true; - const WCHAR *newvFrom = L"3", *newvTo = L"57"; - vm.UpdateDisplay(newvFrom, newvTo); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvFrom)); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvTo)); + vm.UpdateDisplay(L"3", L"57"); + VERIFY_IS_TRUE(vm.Value1 == L"3"); + VERIFY_IS_TRUE(vm.Value2 == L"57"); } TEST_METHOD(TestUnitChangeAfterSwitchingActiveTwiceUpdateUnitsCorrectly) @@ -716,10 +705,9 @@ TEST_METHOD(TestCategoryChangeAfterSwitchingActiveTwiceUpdatesDisplayCorrectly) VERIFY_IS_TRUE(UNIT9 == mock->m_curFrom); VERIFY_IS_TRUE(UNIT7 == mock->m_curTo); VERIFY_ARE_EQUAL((UINT)2, mock->m_switchActiveCallCount); - const wchar_t *newvFrom = L"5", *newvTo = L"7"; - vm.UpdateDisplay(newvFrom, newvTo); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvFrom)); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvTo)); + vm.UpdateDisplay(L"5", L"7"); + VERIFY_IS_TRUE(vm.Value1 == L"5"); + VERIFY_IS_TRUE(vm.Value2 == L"7"); } // There is a 100 ms fudge time for the time based tests below @@ -739,11 +727,11 @@ TEST_METHOD(TestSuggestedValuesCallbackUpdatesSupplementaryResults) WaitForSingleObjectEx(GetCurrentThread(), 200, FALSE); // Now we should see it VERIFY_ARE_EQUAL((UINT)3, vm.SupplementaryResults->Size); - VERIFY_IS_TRUE((AddUnicodeLTRMarkers(L"1")) == vm.SupplementaryResults->GetAt(0)->Value); + VERIFY_IS_TRUE(L"1" == vm.SupplementaryResults->GetAt(0)->Value); VERIFY_IS_TRUE(UNIT1 == vm.SupplementaryResults->GetAt(0)->Unit->GetModelUnit()); - VERIFY_IS_TRUE((AddUnicodeLTRMarkers(L"2")) == vm.SupplementaryResults->GetAt(1)->Value); + VERIFY_IS_TRUE(L"2" == vm.SupplementaryResults->GetAt(1)->Value); VERIFY_IS_TRUE(UNIT2 == vm.SupplementaryResults->GetAt(1)->Unit->GetModelUnit()); - VERIFY_IS_TRUE((AddUnicodeLTRMarkers(L"3")) == vm.SupplementaryResults->GetAt(2)->Value); + VERIFY_IS_TRUE(L"3" == vm.SupplementaryResults->GetAt(2)->Value); VERIFY_IS_TRUE(UNIT3 == vm.SupplementaryResults->GetAt(2)->Unit->GetModelUnit()); } @@ -938,14 +926,14 @@ TEST_METHOD(TestDecimalFormattingLogic) const WCHAR *vFrom = L"3.", *vTo = L"2.50"; vm.UpdateDisplay(vFrom, vTo); // Establish base condition - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3.")); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); + VERIFY_IS_TRUE(vm.Value1 == L"3."); + VERIFY_IS_TRUE(vm.Value2 == L"2.50"); vm.SwitchActive->Execute(nullptr); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3")); // dangling decimal now removed - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); + VERIFY_IS_TRUE(vm.Value1 == L"3"); // dangling decimal now removed + VERIFY_IS_TRUE(vm.Value2 == L"2.50"); vm.SwitchActive->Execute(nullptr); - VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3")); - VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); + VERIFY_IS_TRUE(vm.Value1 == L"3"); + VERIFY_IS_TRUE(vm.Value2 == L"2.50"); } // Tests that when we switch the active field and get display // updates, the correct automation names are are being updated. diff --git a/src/GraphControl/Utils.h b/src/GraphControl/Utils.h index f94b928b..70241b0a 100644 --- a/src/GraphControl/Utils.h +++ b/src/GraphControl/Utils.h @@ -219,10 +219,6 @@ namespace Utils }; } - const wchar_t LRE = 0x202a; // Left-to-Right Embedding - const wchar_t PDF = 0x202c; // Pop Directional Formatting - const wchar_t LRO = 0x202d; // Left-to-Right Override - // Regular DependencyProperty template Windows::UI::Xaml::DependencyProperty^ RegisterDependencyProperty(