Remove LRE/LRO characters from results and error messages (#1161)

* Remove LRE/LRO characters and rely on Xaml to correctly displayed the numbers and error messages RtL

* unit tests
This commit is contained in:
Rudy Huyn 2020-04-30 12:04:33 -07:00 committed by GitHub
parent 2cafb0dc88
commit 6e521d8f29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 127 additions and 188 deletions

View file

@ -45,12 +45,7 @@ unsigned int CalculatorHistory::AddToHistory(
spHistoryItem->historyItemVector.spTokens = tokens; spHistoryItem->historyItemVector.spTokens = tokens;
spHistoryItem->historyItemVector.spCommands = commands; spHistoryItem->historyItemVector.spCommands = commands;
spHistoryItem->historyItemVector.expression = GetGeneratedExpression(*tokens);
// 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.result = wstring(result); spHistoryItem->historyItemVector.result = wstring(result);
return AddItem(spHistoryItem); return AddItem(spHistoryItem);
} }

View file

@ -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 // Regular DependencyProperty
template <typename TOwner, typename TType> template <typename TOwner, typename TType>

View file

@ -134,23 +134,14 @@ StandardCalculatorViewModel::StandardCalculatorViewModel()
AreProgrammerRadixOperatorsEnabled = false; AreProgrammerRadixOperatorsEnabled = false;
} }
String ^ StandardCalculatorViewModel::LocalizeDisplayValue(_In_ wstring const& displayValue, _In_ bool isError) String ^ StandardCalculatorViewModel::LocalizeDisplayValue(_In_ wstring const& displayValue)
{ {
wstring result(displayValue); wstring result(displayValue);
LocalizationSettings::GetInstance().LocalizeDisplayValue(&result); 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()); 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 ^ localizedValue = localizedDisplayValue;
String ^ automationFormat = m_localizedCalculationResultAutomationFormat; String ^ automationFormat = m_localizedCalculationResultAutomationFormat;
@ -159,7 +150,7 @@ String ^ StandardCalculatorViewModel::CalculateNarratorDisplayValue(_In_ wstring
if (Utils::IsLastCharacterTarget(displayValue, m_decimalSeparator)) if (Utils::IsLastCharacterTarget(displayValue, m_decimalSeparator))
{ {
// remove the decimal separator, to avoid a long pause between words // 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 // Use a format which has a word in the decimal separator's place
// "The Display is 10 point" // "The Display is 10 point"
@ -195,11 +186,11 @@ String ^ StandardCalculatorViewModel::GetNarratorStringReadRawNumbers(_In_ Strin
void StandardCalculatorViewModel::SetPrimaryDisplay(_In_ String ^ displayStringValue, _In_ bool isError) 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 // Set this variable before the DisplayValue is modified, Otherwise the DisplayValue will
// not match what the narrator is saying // not match what the narrator is saying
m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue->Data(), localizedDisplayStringValue, isError); m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue->Data(), localizedDisplayStringValue);
AreAlwaysOnTopResultsUpdated = false; AreAlwaysOnTopResultsUpdated = false;
if (DisplayValue != localizedDisplayStringValue) if (DisplayValue != localizedDisplayStringValue)
@ -418,7 +409,7 @@ void StandardCalculatorViewModel::SetMemorizedNumbers(const vector<wstring>& new
MemoryItemViewModel ^ memorySlot = ref new MemoryItemViewModel(this); MemoryItemViewModel ^ memorySlot = ref new MemoryItemViewModel(this);
memorySlot->Position = 0; memorySlot->Position = 0;
localizer.LocalizeDisplayValue(&stringValue); 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); MemorizedNumbers->InsertAt(0, memorySlot);
IsMemoryEmpty = IsAlwaysOnTop; IsMemoryEmpty = IsAlwaysOnTop;
@ -440,7 +431,7 @@ void StandardCalculatorViewModel::SetMemorizedNumbers(const vector<wstring>& new
// If the value is different, update the value // If the value is different, update the value
if (MemorizedNumbers->GetAt(i)->Value != StringReference(newStringValue.c_str())) 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(&octalDisplayString);
localizer.LocalizeDisplayValue(&binaryDisplayString); localizer.LocalizeDisplayValue(&binaryDisplayString);
HexDisplayValue = Utils::LRO + ref new Platform::String(hexDisplayString.c_str()) + Utils::PDF; HexDisplayValue = ref new Platform::String(hexDisplayString.c_str());
DecimalDisplayValue = Utils::LRO + ref new Platform::String(decimalDisplayString.c_str()) + Utils::PDF; DecimalDisplayValue = ref new Platform::String(decimalDisplayString.c_str());
OctalDisplayValue = Utils::LRO + ref new Platform::String(octalDisplayString.c_str()) + Utils::PDF; OctalDisplayValue = ref new Platform::String(octalDisplayString.c_str());
BinaryDisplayValue = Utils::LRO + ref new Platform::String(binaryDisplayString.c_str()) + Utils::PDF; BinaryDisplayValue = ref new Platform::String(binaryDisplayString.c_str());
HexDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedHexaDecimalAutomationFormat, GetNarratorStringReadRawNumbers(HexDisplayValue)); HexDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedHexaDecimalAutomationFormat, GetNarratorStringReadRawNumbers(HexDisplayValue));
DecDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedDecimalAutomationFormat, DecimalDisplayValue); DecDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedDecimalAutomationFormat, DecimalDisplayValue);
OctDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedOctalAutomationFormat, GetNarratorStringReadRawNumbers(OctalDisplayValue)); OctDisplayValue_AutomationName = GetLocalizedStringFormat(m_localizedOctalAutomationFormat, GetNarratorStringReadRawNumbers(OctalDisplayValue));

View file

@ -341,9 +341,9 @@ namespace CalculatorApp
Platform::String ^ m_selectedExpressionLastData; Platform::String ^ m_selectedExpressionLastData;
Common::DisplayExpressionToken ^ m_selectedExpressionToken; 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 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(); CalculatorApp::Common::Automation::NarratorAnnouncement ^ GetDisplayUpdatedNarratorAnnouncement();
Platform::String ^ GetCalculatorExpressionAutomationName(); Platform::String ^ GetCalculatorExpressionAutomationName();
Platform::String ^ GetNarratorStringReadRawNumbers(_In_ Platform::String ^ localizedDisplayValue); Platform::String ^ GetNarratorStringReadRawNumbers(_In_ Platform::String ^ localizedDisplayValue);

View file

@ -381,7 +381,6 @@ String ^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& st
} }
result = L"-" + result; result = L"-" + result;
} }
result = Utils::LRE + result + Utils::PDF;
return result; return result;
} }

View file

@ -577,7 +577,9 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Controls:CalculationResult"> <ControlTemplate TargetType="Controls:CalculationResult">
<Grid x:Name="Border" Background="{TemplateBinding Background}"> <Grid x:Name="Border"
Background="{TemplateBinding Background}"
FlowDirection="LeftToRight">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="12"/> <ColumnDefinition Width="12"/>
<ColumnDefinition/> <ColumnDefinition/>

View file

@ -215,7 +215,7 @@ void CalculationResult::UpdateTextState()
auto containerSize = m_textContainer->ActualWidth; auto containerSize = m_textContainer->ActualWidth;
String ^ oldText = m_textBlock->Text; String ^ oldText = m_textBlock->Text;
String ^ newText = Utils::LRO + DisplayValue + Utils::PDF; String ^ newText = DisplayValue;
// Initiate the scaling operation // Initiate the scaling operation
// UpdateLayout will keep calling us until we make it through the below 2 if-statements // UpdateLayout will keep calling us until we make it through the below 2 if-statements

View file

@ -37,7 +37,9 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:OverflowTextBlock"> <ControlTemplate TargetType="controls:OverflowTextBlock">
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}"> <Grid x:Name="TokenContainer"
Background="{TemplateBinding Background}"
FlowDirection="LeftToRight">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="12"/> <ColumnDefinition Width="12"/>
<ColumnDefinition/> <ColumnDefinition/>
@ -96,7 +98,9 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:OverflowTextBlock"> <ControlTemplate TargetType="controls:OverflowTextBlock">
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}"> <Grid x:Name="TokenContainer"
Background="{TemplateBinding Background}"
FlowDirection="LeftToRight">
<Grid.Resources> <Grid.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.ThemeDictionaries> <ResourceDictionary.ThemeDictionaries>

View file

@ -163,7 +163,8 @@
<Grid x:Name="ProgrammerOperators" <Grid x:Name="ProgrammerOperators"
x:Uid="RadixGroup" x:Uid="RadixGroup"
MaxHeight="244" MaxHeight="244"
AutomationProperties.HeadingLevel="Level1"> AutomationProperties.HeadingLevel="Level1"
FlowDirection="LeftToRight">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*" MinHeight="0"/> <RowDefinition Height="1*" MinHeight="0"/>
<RowDefinition Height="1*" MinHeight="0"/> <RowDefinition Height="1*" MinHeight="0"/>

View file

@ -2,10 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:automation="using:CalculatorApp.Common.Automation" xmlns:automation="using:CalculatorApp.Common.Automation"
xmlns:controls="using:CalculatorApp.Controls"
xmlns:converters="using:CalculatorApp.Converters" xmlns:converters="using:CalculatorApp.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:CalculatorApp.ViewModel" xmlns:model="using:CalculatorApp.ViewModel"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"

View file

@ -1,13 +1,8 @@
<UserControl x:Class="CalculatorApp.MemoryListItem" <UserControl x:Class="CalculatorApp.MemoryListItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:CalculatorApp.Common"
xmlns:controls="using:CalculatorApp.Controls"
xmlns:converters="using:CalculatorApp.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:CalculatorApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:CalculatorApp.ViewModel"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
x:Name="MemoryListItem" x:Name="MemoryListItem"
FlowDirection="LeftToRight" FlowDirection="LeftToRight"

View file

@ -237,7 +237,6 @@
<ClCompile Include="CopyPasteManagerTest.cpp" /> <ClCompile Include="CopyPasteManagerTest.cpp" />
<ClCompile Include="CurrencyConverterUnitTests.cpp" /> <ClCompile Include="CurrencyConverterUnitTests.cpp" />
<ClCompile Include="DateCalculatorUnitTests.cpp" /> <ClCompile Include="DateCalculatorUnitTests.cpp" />
<ClCompile Include="Helper.cpp" />
<ClCompile Include="HistoryTests.cpp" /> <ClCompile Include="HistoryTests.cpp" />
<ClCompile Include="LocalizationServiceUnitTests.cpp" /> <ClCompile Include="LocalizationServiceUnitTests.cpp" />
<ClCompile Include="LocalizationSettingsUnitTests.cpp" /> <ClCompile Include="LocalizationSettingsUnitTests.cpp" />

View file

@ -30,7 +30,6 @@
<ClCompile Include="LocalizationServiceUnitTests.cpp" /> <ClCompile Include="LocalizationServiceUnitTests.cpp" />
<ClCompile Include="RationalTest.cpp" /> <ClCompile Include="RationalTest.cpp" />
<ClCompile Include="LocalizationSettingsUnitTests.cpp" /> <ClCompile Include="LocalizationSettingsUnitTests.cpp" />
<ClCompile Include="Helper.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="DateUtils.h" /> <ClInclude Include="DateUtils.h" />

View file

@ -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;
}

View file

@ -22,9 +22,6 @@ namespace CalculatorUnitTests
namespace UtfUtils 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 constexpr wchar_t MUL = 0x00d7; // Multiplication Symbol
} }
} }
@ -108,5 +105,3 @@ void VERIFY_VECTORS_ARE_EQUAL(Windows::Foundation::Collections::IVector<T> ^ vec
VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i), __VA_ARGS__); VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i), __VA_ARGS__);
} }
}; };
Platform::String ^ GetStringValue(Platform::String ^ input);

View file

@ -80,7 +80,7 @@ namespace CalculatorFunctionalTests
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
int sizeAfterItemAdd = m_historyViewModel->ItemSize; int sizeAfterItemAdd = m_historyViewModel->ItemSize;
auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(0)); auto historyItem = static_cast<HistoryItemViewModel ^>(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(initialSize + 1, sizeAfterItemAdd);
VERIFY_ARE_EQUAL(historyItem->Expression, expression); VERIFY_ARE_EQUAL(historyItem->Expression, expression);
VERIFY_ARE_EQUAL(historyItem->Result, L"9"); VERIFY_ARE_EQUAL(historyItem->Result, L"9");
@ -102,7 +102,7 @@ namespace CalculatorFunctionalTests
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
} }
VERIFY_ARE_EQUAL((size_t)m_historyViewModel->ItemSize, m_historyViewModel->GetMaxItemSize()); 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; int output = 2;
String ^ result = output.ToString(); String ^ result = output.ToString();
auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1)); auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1));
@ -112,7 +112,7 @@ namespace CalculatorFunctionalTests
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandADD)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandADD));
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::Command5)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::Command5));
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
expression = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF; expression = L"1 + 2 =";
output = 3; output = 3;
result = output.ToString(); result = output.ToString();
historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1)); historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1));
@ -154,7 +154,6 @@ namespace CalculatorFunctionalTests
for (int i = 0; i < scientificItems; i++) for (int i = 0; i < scientificItems; i++)
{ {
wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" ="; wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" =";
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
int output = 1 + i; int output = 1 + i;
String ^ result = output.ToString(); String ^ result = output.ToString();
auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i)); auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i));
@ -168,7 +167,6 @@ namespace CalculatorFunctionalTests
for (int i = 0; i < standardItems; i++) for (int i = 0; i < standardItems; i++)
{ {
wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" ="; wstring expr = L"1 + " + wstring(i.ToString()->Data()) + L" =";
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
int output = 1 + i; int output = 1 + i;
String ^ result = output.ToString(); String ^ result = output.ToString();
auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i)); auto historyItem = static_cast<HistoryItemViewModel ^>(m_historyViewModel->Items->GetAt(m_historyViewModel->ItemSize - 1 - i));
@ -238,8 +236,6 @@ namespace CalculatorFunctionalTests
m_historyViewModel->ReloadHistory(ViewMode::Scientific); m_historyViewModel->ReloadHistory(ViewMode::Scientific);
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::ModeScientific)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::ModeScientific));
wstring expr = L"1 + 8 ="; wstring expr = L"1 + 8 =";
// add double quotes around the expression
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
String ^ result = StringReference(L"9"); String ^ result = StringReference(L"9");
int itemsAfterSaveAndReload = m_historyViewModel->ItemSize; int itemsAfterSaveAndReload = m_historyViewModel->ItemSize;
@ -275,7 +271,6 @@ namespace CalculatorFunctionalTests
String ^ expression = m_uiResourceLoader->GetString(commandResource.ToString()); String ^ expression = m_uiResourceLoader->GetString(commandResource.ToString());
expression += L"( 1 ) ="; expression += L"( 1 ) =";
wstring expr = wstring(expression->Data()); wstring expr = wstring(expression->Data());
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str())); VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str()));
commandResource++; commandResource++;
itemIndex++; itemIndex++;
@ -309,7 +304,6 @@ namespace CalculatorFunctionalTests
expression += m_uiResourceLoader->GetString(L"79"); expression += m_uiResourceLoader->GetString(L"79");
expression += L"( 1 ) ="; expression += L"( 1 ) =";
wstring expr = wstring(expression->Data()); wstring expr = wstring(expression->Data());
expr = UtfUtils::LRO + expr + UtfUtils::PDF;
VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str())); VERIFY_ARE_EQUAL(historyItem->Expression, StringReference(expr.c_str()));
Cleanup(); Cleanup();
@ -406,13 +400,13 @@ namespace CalculatorFunctionalTests
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::Command7)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::Command7));
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU)); m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
String ^ expression = L"HexaDecimal" + L" 8"; 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); VERIFY_ARE_EQUAL(expression, result);
expression = StringReference(L"Octal 10"); expression = StringReference(L"Octal 10");
result = L"Octal " + GetStringValue(m_standardViewModel->OctalDisplayValue); result = L"Octal " + m_standardViewModel->OctalDisplayValue;
VERIFY_ARE_EQUAL(expression, result); VERIFY_ARE_EQUAL(expression, result);
expression = StringReference(L"Binary 1000"); expression = StringReference(L"Binary 1000");
result = L"Binary " + GetStringValue(m_standardViewModel->BinaryDisplayValue); result = L"Binary " + m_standardViewModel->BinaryDisplayValue;
VERIFY_ARE_EQUAL(expression, result); VERIFY_ARE_EQUAL(expression, result);
Cleanup(); Cleanup();
} }

View file

@ -132,14 +132,14 @@ TEST_METHOD(MultipleModesCalculationTest)
{ NumbersAndOperatorsEnum::F, L"F", L"" }, { NumbersAndOperatorsEnum::F, L"F", L"" },
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(viewModels[2], programmerModeTestItems, false); ValidateViewModelByCommands(viewModels[2], programmerModeTestItems, false);
VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->HexDisplayValue), StringReference(L"F")); VERIFY_ARE_EQUAL(viewModels[2]->HexDisplayValue, StringReference(L"F"));
VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(viewModels[2]->DecimalDisplayValue, StringReference(L"15"));
VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(viewModels[2]->OctalDisplayValue, StringReference(L"17"));
VERIFY_ARE_EQUAL(GetStringValue(viewModels[2]->BinaryDisplayValue), StringReference(L"1111")); VERIFY_ARE_EQUAL(viewModels[2]->BinaryDisplayValue, StringReference(L"1111"));
// Assert that Standard and Scientific mode Display Values are unchanged // Assert that Standard and Scientific mode Display Values are unchanged
VERIFY_ARE_EQUAL(GetStringValue(viewModels[0]->DisplayValue), StringReference(L"3")); VERIFY_ARE_EQUAL(viewModels[0]->DisplayValue, StringReference(L"3"));
VERIFY_ARE_EQUAL(GetStringValue(viewModels[1]->DisplayValue), StringReference(L"7")); 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 // 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); ValidateViewModelByCommands(standardViewModel2, standardModeTestItems2, true);
// Assert that the Display Value of 1st instance is unchanged // 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 // 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); ValidateViewModelByCommands(scientificViewModel2, scientificModeTestItems2, true);
// Assert that the Display Value of 1st instance is unchanged // 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 // Perform calculations on 2 instances of Calculator in Scientific Mode
@ -274,10 +274,10 @@ TEST_METHOD(MultipleProgrammerModeCalculationTest)
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false); ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false);
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"F")); VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"F"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"15"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"17"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111")); VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111"));
// Radix Type: Octal, Expression: 7 // Radix Type: Octal, Expression: 7
TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::OctButton, L"0", L"" }, TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::OctButton, L"0", L"" },
@ -285,17 +285,17 @@ TEST_METHOD(MultipleProgrammerModeCalculationTest)
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false); ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false);
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->HexDisplayValue), StringReference(L"7")); VERIFY_ARE_EQUAL(programmerViewModel2->HexDisplayValue, StringReference(L"7"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->DecimalDisplayValue), StringReference(L"7")); VERIFY_ARE_EQUAL(programmerViewModel2->DecimalDisplayValue, StringReference(L"7"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->OctalDisplayValue), StringReference(L"7")); VERIFY_ARE_EQUAL(programmerViewModel2->OctalDisplayValue, StringReference(L"7"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->BinaryDisplayValue), StringReference(L"0111")); VERIFY_ARE_EQUAL(programmerViewModel2->BinaryDisplayValue, StringReference(L"0111"));
// Assert that displayed values of 1st instance are unchanged // Assert that displayed values of 1st instance are unchanged
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DisplayValue), StringReference(L"F")); VERIFY_ARE_EQUAL(programmerViewModel1->DisplayValue, StringReference(L"F"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"F")); VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"F"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"15"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"17"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111")); VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111"));
} }
// Perform calculations on 2 instances of Calculator in Programmer Mode // Perform calculations on 2 instances of Calculator in Programmer Mode
@ -335,10 +335,10 @@ TEST_METHOD(MultipleProgrammerModeWithDifferentSettingsTest)
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false); ValidateViewModelByCommands(programmerViewModel1, programmerModeTestItems1, false);
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->HexDisplayValue), StringReference(L"FF")); VERIFY_ARE_EQUAL(programmerViewModel1->HexDisplayValue, StringReference(L"FF"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->DecimalDisplayValue), StringReference(L"-1")); VERIFY_ARE_EQUAL(programmerViewModel1->DecimalDisplayValue, StringReference(L"-1"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->OctalDisplayValue), StringReference(L"377")); VERIFY_ARE_EQUAL(programmerViewModel1->OctalDisplayValue, StringReference(L"377"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel1->BinaryDisplayValue), StringReference(L"1111 1111")); VERIFY_ARE_EQUAL(programmerViewModel1->BinaryDisplayValue, StringReference(L"1111 1111"));
TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::Seven, L"7", L"" }, TESTITEM programmerModeTestItems2[] = { { NumbersAndOperatorsEnum::Seven, L"7", L"" },
{ NumbersAndOperatorsEnum::Seven, L"77", L"" }, { NumbersAndOperatorsEnum::Seven, L"77", L"" },
@ -350,10 +350,10 @@ TEST_METHOD(MultipleProgrammerModeWithDifferentSettingsTest)
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false); ValidateViewModelByCommands(programmerViewModel2, programmerModeTestItems2, false);
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->HexDisplayValue), StringReference(L"7FFF")); VERIFY_ARE_EQUAL(programmerViewModel2->HexDisplayValue, StringReference(L"7FFF"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->DecimalDisplayValue), StringReference(L"32,767")); VERIFY_ARE_EQUAL(programmerViewModel2->DecimalDisplayValue, StringReference(L"32,767"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->OctalDisplayValue), StringReference(L"77 777")); VERIFY_ARE_EQUAL(programmerViewModel2->OctalDisplayValue, StringReference(L"77 777"));
VERIFY_ARE_EQUAL(GetStringValue(programmerViewModel2->BinaryDisplayValue), StringReference(L"0111 1111 1111 1111")); 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 // 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 // Assert for the history list items of 1st instance
VERIFY_IS_TRUE(1 == viewModels[0]->HistoryVM->ItemSize); VERIFY_IS_TRUE(1 == viewModels[0]->HistoryVM->ItemSize);
auto item1 = static_cast<HistoryItemViewModel^>(viewModels[0]->HistoryVM->Items->GetAt(0)); auto item1 = static_cast<HistoryItemViewModel ^>(viewModels[0]->HistoryVM->Items->GetAt(0));
String ^ expression1 = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF; String ^ expression1 = L"1 + 2 =";
String ^ result1 = L"3"; String ^ result1 = L"3";
VERIFY_ARE_EQUAL(expression1, item1->Expression); VERIFY_ARE_EQUAL(expression1, item1->Expression);
@ -402,8 +402,8 @@ TEST_METHOD(MultipleModesHistoryAddItemTest)
// Assert for the history list items of 2nd instance // Assert for the history list items of 2nd instance
VERIFY_IS_TRUE(1 == viewModels[1]->HistoryVM->ItemSize); VERIFY_IS_TRUE(1 == viewModels[1]->HistoryVM->ItemSize);
auto item2 = static_cast<HistoryItemViewModel^>(viewModels[1]->HistoryVM->Items->GetAt(0)); auto item2 = static_cast<HistoryItemViewModel ^>(viewModels[1]->HistoryVM->Items->GetAt(0));
String ^ expression2 = UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + UtfUtils::PDF; String ^ expression2 = L"1 + 2 " + UtfUtils::MUL + L" 3 =";
String ^ result2 = L"7"; String ^ result2 = L"7";
VERIFY_ARE_EQUAL(expression2, item2->Expression); VERIFY_ARE_EQUAL(expression2, item2->Expression);
@ -451,7 +451,7 @@ TEST_METHOD(MultipleStandardModesHistoryAddItemTest)
ValidateViewModelByCommands(viewModels[i], standardModeTestItems[i], true); 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" }; String ^ result[] = { L"3", L"7" };
// Assert for the history list items of the instances // Assert for the history list items of the instances
@ -507,7 +507,7 @@ TEST_METHOD(MultipleScientificModesHistoryAddItemTest)
ValidateViewModelByCommands(viewModels[i], standardModeTestItems[i], true); 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" }; String ^ result[] = { L"3", L"9" };
// Assert for the history list items of the instances // Assert for the history list items of the instances
@ -515,7 +515,7 @@ TEST_METHOD(MultipleScientificModesHistoryAddItemTest)
{ {
VERIFY_IS_TRUE(1 == viewModels[i]->HistoryVM->ItemSize); VERIFY_IS_TRUE(1 == viewModels[i]->HistoryVM->ItemSize);
auto item = static_cast<HistoryItemViewModel^>(viewModels[i]->HistoryVM->Items->GetAt(0)); auto item = static_cast<HistoryItemViewModel ^>(viewModels[i]->HistoryVM->Items->GetAt(0));
VERIFY_ARE_EQUAL(expression[i], item->Expression); VERIFY_ARE_EQUAL(expression[i], item->Expression);
VERIFY_ARE_EQUAL(result[i], item->Result); VERIFY_ARE_EQUAL(result[i], item->Result);
@ -567,7 +567,7 @@ TEST_METHOD(MultipleModesMemoryAddItemTest)
viewModels[i]->ButtonPressed->Execute(NumbersAndOperatorsEnum::Memory); 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 // Validate that only one item is present in the memory
// Also assert for their value // Also assert for their value
@ -781,7 +781,7 @@ TEST_METHOD(MultipleConverterModeCalculationTest)
auto expectedValue1 = (i + 1).ToString(); auto expectedValue1 = (i + 1).ToString();
auto actualValue1 = viewModels[i]->Value1; 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 unit1Name = viewModels[i]->Unit1->Name->Data();
std::wstring unit2Name = viewModels[i]->Unit2->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); auto resKey = String::Concat(ref new String((unit1Name + L"-" + unit2Name + L"-").c_str()), expectedValue1);
String ^ expectedResult = resLoader->GetString(resKey); String ^ expectedResult = resLoader->GetString(resKey);
String ^ actualResult = GetStringValue(viewModels[i]->Value2); String ^ actualResult = viewModels[i]->Value2;
VERIFY_ARE_EQUAL(expectedResult, actualResult); VERIFY_ARE_EQUAL(expectedResult, actualResult);
} }
@ -860,11 +860,11 @@ TEST_METHOD(TestStandardUnitConverterAndDateViewModels)
unitConverterViewModel->ButtonPressed->Execute(NumbersAndOperatorsEnum::Two); unitConverterViewModel->ButtonPressed->Execute(NumbersAndOperatorsEnum::Two);
// Validate the Result // Validate the Result
VERIFY_ARE_EQUAL(StringReference(L"2"), GetStringValue(unitConverterViewModel->Value1)); VERIFY_ARE_EQUAL(StringReference(L"2"), unitConverterViewModel->Value1);
VERIFY_ARE_EQUAL(StringReference(L"0.002"), GetStringValue(unitConverterViewModel->Value2)); VERIFY_ARE_EQUAL(StringReference(L"0.002"), unitConverterViewModel->Value2);
// Assert that the Display Value of Standard Calc instance is unchanged // 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 // 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::Equals, L"3", L"" },
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(standardViewModel, standardModeTestItems2, true); 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 // Validate the Date Calculator
VERIFY_ARE_EQUAL(DateUtils::GetLongDate(endDate), dateCalcViewModel->StrDateResult); VERIFY_ARE_EQUAL(DateUtils::GetLongDate(endDate), dateCalcViewModel->StrDateResult);
// Validate the Unit Converter // Validate the Unit Converter
VERIFY_ARE_EQUAL(StringReference(L"2"), GetStringValue(unitConverterViewModel->Value1)); VERIFY_ARE_EQUAL(StringReference(L"2"), unitConverterViewModel->Value1);
VERIFY_ARE_EQUAL(StringReference(L"0.002"), GetStringValue(unitConverterViewModel->Value2)); VERIFY_ARE_EQUAL(StringReference(L"0.002"), unitConverterViewModel->Value2);
} }
// Change the radix in programmer mode and check that other modes are not affected // 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::F, L"F", L"" },
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(viewModels[1], programmerModeTestItems, false /*doReset*/); 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= // Standard Mode: Expression 10+2=
// Radix should be decimal, not hex // Radix should be decimal, not hex
@ -930,7 +930,7 @@ TEST_METHOD(MultipleModesWithChangeInProgrammerRadix)
{ NumbersAndOperatorsEnum::Equals, L"B", L"" }, { NumbersAndOperatorsEnum::Equals, L"B", L"" },
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(viewModels[1], programmerModeTestItemsNew, true /*doReset*/); 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"));
} }
} }
; ;

View file

@ -495,10 +495,10 @@ namespace CalculatorUnitTests
{ NumbersAndOperatorsEnum::F, L"F", L"" }, { NumbersAndOperatorsEnum::F, L"F", L"" },
{ NumbersAndOperatorsEnum::None, L"", L"" } }; { NumbersAndOperatorsEnum::None, L"", L"" } };
ValidateViewModelByCommands(m_viewModel, items, false); ValidateViewModelByCommands(m_viewModel, items, false);
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"F")); VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"F"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15")); VERIFY_ARE_EQUAL(m_viewModel->DecimalDisplayValue, StringReference(L"15"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17")); VERIFY_ARE_EQUAL(m_viewModel->OctalDisplayValue, StringReference(L"17"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111")); VERIFY_ARE_EQUAL(m_viewModel->BinaryDisplayValue, StringReference(L"1111"));
auto val = ref new Platform::Collections::Vector<bool>(64, false); auto val = ref new Platform::Collections::Vector<bool>(64, false);
val->SetAt(0, true); val->SetAt(0, true);
val->SetAt(1, true); val->SetAt(1, true);
@ -548,10 +548,10 @@ namespace CalculatorUnitTests
{ NumbersAndOperatorsEnum::None, L"1", L"" }, { NumbersAndOperatorsEnum::None, L"1", L"" },
}; };
ValidateViewModelByCommands(m_viewModel, items, true); ValidateViewModelByCommands(m_viewModel, items, true);
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"75B CD15")); VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"75B CD15"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789")); VERIFY_ARE_EQUAL(m_viewModel->DecimalDisplayValue, StringReference(L"123,456,789"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425")); VERIFY_ARE_EQUAL(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->BinaryDisplayValue, StringReference(L"0111 0101 1011 1100 1101 0001 0101"));
auto val = ref new Platform::Collections::Vector<bool>(64, false); auto val = ref new Platform::Collections::Vector<bool>(64, false);
val->SetAt(0, true); val->SetAt(0, true);
val->SetAt(2, true); val->SetAt(2, true);
@ -582,11 +582,11 @@ namespace CalculatorUnitTests
{ NumbersAndOperatorsEnum::Not, L"-2", L"~(1)" }, { NumbersAndOperatorsEnum::Not, L"-2", L"~(1)" },
{ NumbersAndOperatorsEnum::None, L"N/A", L"N/A" } }; { NumbersAndOperatorsEnum::None, L"N/A", L"N/A" } };
ValidateViewModelByCommands(m_viewModel, items, false); ValidateViewModelByCommands(m_viewModel, items, false);
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->HexDisplayValue), StringReference(L"FFFF FFFF FFFF FFFE")); VERIFY_ARE_EQUAL(m_viewModel->HexDisplayValue, StringReference(L"FFFF FFFF FFFF FFFE"));
VERIFY_ARE_EQUAL(GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"-2")); VERIFY_ARE_EQUAL(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->OctalDisplayValue, StringReference(L"1 777 777 777 777 777 777 776"));
VERIFY_ARE_EQUAL( 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")); 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")); VERIFY_ARE_EQUAL(m_viewModel->DisplayValue, StringReference(L"-2"));
auto val = ref new Platform::Collections::Vector<bool>(64, true); auto val = ref new Platform::Collections::Vector<bool>(64, true);
@ -776,13 +776,13 @@ namespace CalculatorUnitTests
m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(0)); m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(0));
VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), m_viewModel->DisplayValue); VERIFY_ARE_EQUAL(Platform::StringReference(L"-1,001"), m_viewModel->DisplayValue);
MemoryItemViewModel ^ memorySlotStandard = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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*/); ChangeMode(m_viewModel, 1 /*scientific*/);
MemoryItemViewModel ^ memorySlotScientific = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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*/); ChangeMode(m_viewModel, 2 /*Programmer*/);
MemoryItemViewModel ^ memorySlotProgrammer = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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 // When decimal number is saved in memory
@ -800,13 +800,13 @@ namespace CalculatorUnitTests
m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(0)); m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(0));
VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), m_viewModel->DisplayValue); VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), m_viewModel->DisplayValue);
MemoryItemViewModel ^ memorySlotStandard = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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*/); ChangeMode(m_viewModel, 1 /*Scientific*/);
MemoryItemViewModel ^ memorySlotScientific = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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*/); ChangeMode(m_viewModel, 2 /*Programmer*/);
MemoryItemViewModel ^ memorySlotProgrammer = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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 // When negative decimal number is saved in memory
@ -865,7 +865,7 @@ namespace CalculatorUnitTests
m_viewModel->OnMemoryItemPressed(ref new Box<int>(0)); m_viewModel->OnMemoryItemPressed(ref new Box<int>(0));
VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), m_viewModel->DisplayValue); VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), m_viewModel->DisplayValue);
MemoryItemViewModel ^ memorySlot = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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) TEST_METHOD(OnMemorySavedInHexRadixAndRadixChanges)
@ -881,13 +881,13 @@ namespace CalculatorUnitTests
m_viewModel->OnMemoryButtonPressed(); m_viewModel->OnMemoryButtonPressed();
m_viewModel->SwitchProgrammerModeBase(NumberBase::OctBase); m_viewModel->SwitchProgrammerModeBase(NumberBase::OctBase);
MemoryItemViewModel ^ memorySlotOct = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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); m_viewModel->SwitchProgrammerModeBase(NumberBase::DecBase);
MemoryItemViewModel ^ memorySlotDec = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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); m_viewModel->SwitchProgrammerModeBase(NumberBase::BinBase);
MemoryItemViewModel ^ memorySlotBin = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0); 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, // When memory button is pressed more than max number of slots allowed,
@ -966,7 +966,7 @@ namespace CalculatorUnitTests
m_viewModel->OnMemoryItemPressed(1); m_viewModel->OnMemoryItemPressed(1);
m_viewModel->OnMemoryAdd(ref new Platform::Box<int>(0)); m_viewModel->OnMemoryAdd(ref new Platform::Box<int>(0));
MemoryItemViewModel ^ memorySlot = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(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 // Verify that raw, unformatted numbers are provided correctly

View file

@ -27,13 +27,6 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace CalculatorUnitTests 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) TEST_CLASS(CategoryViewModelTests)
{ {
public: public:
@ -298,7 +291,7 @@ for (unsigned int k = 0; k < categoryList->Size; k++)
wstring expResult = expectedResult->Data(); wstring expResult = expectedResult->Data();
double expectedConversion = GetDoubleFromWstring(expResult); double expectedConversion = GetDoubleFromWstring(expResult);
double actualConversion = GetDoubleFromWstring(GetStringValue(vm->Value1)->Data()); double actualConversion = GetDoubleFromWstring(vm->Value1->Data());
double diff = abs(expectedConversion - actualConversion); double diff = abs(expectedConversion - actualConversion);
// Assert for diff less than epsilonth fraction of expected conversion result // Assert for diff less than epsilonth fraction of expected conversion result
@ -422,10 +415,9 @@ TEST_METHOD(TestDisplayCallbackUpdatesDisplayValues)
{ {
shared_ptr<UnitConverterMock> mock = make_shared<UnitConverterMock>(); shared_ptr<UnitConverterMock> mock = make_shared<UnitConverterMock>();
VM::UnitConverterViewModel vm(mock); VM::UnitConverterViewModel vm(mock);
const WCHAR *vFrom = L"1234", *vTo = L"56.78"; vm.UpdateDisplay(L"1234", L"56.78");
vm.UpdateDisplay(vFrom, vTo); VERIFY_IS_TRUE(vm.Value1 == L"1,234");
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"1,234")); VERIFY_IS_TRUE(vm.Value2 == L"56.78");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(vTo));
} }
// Test that the calculator button command correctly fires // Test that the calculator button command correctly fires
@ -570,10 +562,9 @@ TEST_METHOD(TestDisplayValueUpdatesAfterSwitchingActiveUpdateTheRightDisplay)
const WCHAR *vFrom = L"1", *vTo = L"234"; const WCHAR *vFrom = L"1", *vTo = L"234";
vm.UpdateDisplay(vFrom, vTo); vm.UpdateDisplay(vFrom, vTo);
vm.Value2Active = true; vm.Value2Active = true;
const WCHAR *newvFrom = L"3", *newvTo = L"57"; vm.UpdateDisplay(L"3", L"57");
vm.UpdateDisplay(newvFrom, newvTo); VERIFY_IS_TRUE(vm.Value2 == L"3");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvFrom)); VERIFY_IS_TRUE(vm.Value1 == L"57");
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvTo));
} }
// Tests that when we switch the active field and get change units, // 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(UNIT9 == mock->m_curFrom);
VERIFY_IS_TRUE(UNIT7 == mock->m_curTo); VERIFY_IS_TRUE(UNIT7 == mock->m_curTo);
VERIFY_ARE_EQUAL((UINT)1, mock->m_switchActiveCallCount); VERIFY_ARE_EQUAL((UINT)1, mock->m_switchActiveCallCount);
const wchar_t *newvFrom = L"5", *newvTo = L"7"; vm.UpdateDisplay(L"5", L"7");
vm.UpdateDisplay(newvFrom, newvTo); VERIFY_IS_TRUE(vm.Value2 == L"5");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvFrom)); VERIFY_IS_TRUE(vm.Value1 == L"7");
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvTo));
} }
// Repeat above active switch tests but with a second switch to ensure // Repeat above active switch tests but with a second switch to ensure
@ -682,10 +672,9 @@ TEST_METHOD(TestDisplayValueUpdatesAfterSwitchingActiveTwiceUpdateTheRightDispla
vm.UpdateDisplay(vFrom, vTo); vm.UpdateDisplay(vFrom, vTo);
vm.Value2Active = true; vm.Value2Active = true;
vm.Value1Active = true; vm.Value1Active = true;
const WCHAR *newvFrom = L"3", *newvTo = L"57"; vm.UpdateDisplay(L"3", L"57");
vm.UpdateDisplay(newvFrom, newvTo); VERIFY_IS_TRUE(vm.Value1 == L"3");
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvFrom)); VERIFY_IS_TRUE(vm.Value2 == L"57");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvTo));
} }
TEST_METHOD(TestUnitChangeAfterSwitchingActiveTwiceUpdateUnitsCorrectly) TEST_METHOD(TestUnitChangeAfterSwitchingActiveTwiceUpdateUnitsCorrectly)
@ -716,10 +705,9 @@ TEST_METHOD(TestCategoryChangeAfterSwitchingActiveTwiceUpdatesDisplayCorrectly)
VERIFY_IS_TRUE(UNIT9 == mock->m_curFrom); VERIFY_IS_TRUE(UNIT9 == mock->m_curFrom);
VERIFY_IS_TRUE(UNIT7 == mock->m_curTo); VERIFY_IS_TRUE(UNIT7 == mock->m_curTo);
VERIFY_ARE_EQUAL((UINT)2, mock->m_switchActiveCallCount); VERIFY_ARE_EQUAL((UINT)2, mock->m_switchActiveCallCount);
const wchar_t *newvFrom = L"5", *newvTo = L"7"; vm.UpdateDisplay(L"5", L"7");
vm.UpdateDisplay(newvFrom, newvTo); VERIFY_IS_TRUE(vm.Value1 == L"5");
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(newvFrom)); VERIFY_IS_TRUE(vm.Value2 == L"7");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(newvTo));
} }
// There is a 100 ms fudge time for the time based tests below // There is a 100 ms fudge time for the time based tests below
@ -739,11 +727,11 @@ TEST_METHOD(TestSuggestedValuesCallbackUpdatesSupplementaryResults)
WaitForSingleObjectEx(GetCurrentThread(), 200, FALSE); WaitForSingleObjectEx(GetCurrentThread(), 200, FALSE);
// Now we should see it // Now we should see it
VERIFY_ARE_EQUAL((UINT)3, vm.SupplementaryResults->Size); 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(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(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()); 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"; const WCHAR *vFrom = L"3.", *vTo = L"2.50";
vm.UpdateDisplay(vFrom, vTo); vm.UpdateDisplay(vFrom, vTo);
// Establish base condition // Establish base condition
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3.")); VERIFY_IS_TRUE(vm.Value1 == L"3.");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); VERIFY_IS_TRUE(vm.Value2 == L"2.50");
vm.SwitchActive->Execute(nullptr); vm.SwitchActive->Execute(nullptr);
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3")); // dangling decimal now removed VERIFY_IS_TRUE(vm.Value1 == L"3"); // dangling decimal now removed
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); VERIFY_IS_TRUE(vm.Value2 == L"2.50");
vm.SwitchActive->Execute(nullptr); vm.SwitchActive->Execute(nullptr);
VERIFY_IS_TRUE(vm.Value1 == AddUnicodeLTRMarkers(L"3")); VERIFY_IS_TRUE(vm.Value1 == L"3");
VERIFY_IS_TRUE(vm.Value2 == AddUnicodeLTRMarkers(L"2.50")); VERIFY_IS_TRUE(vm.Value2 == L"2.50");
} }
// Tests that when we switch the active field and get display // Tests that when we switch the active field and get display
// updates, the correct automation names are are being updated. // updates, the correct automation names are are being updated.

View file

@ -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 // Regular DependencyProperty
template <typename TOwner, typename TType> template <typename TOwner, typename TType>
Windows::UI::Xaml::DependencyProperty^ RegisterDependencyProperty( Windows::UI::Xaml::DependencyProperty^ RegisterDependencyProperty(