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:
parent
2cafb0dc88
commit
6e521d8f29
@ -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);
|
||||
}
|
||||
|
@ -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 <typename TOwner, typename TType>
|
||||
|
@ -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<wstring>& 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<wstring>& 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));
|
||||
|
@ -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);
|
||||
|
@ -381,7 +381,6 @@ String ^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& st
|
||||
}
|
||||
result = L"-" + result;
|
||||
}
|
||||
result = Utils::LRE + result + Utils::PDF;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,9 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Controls:CalculationResult">
|
||||
<Grid x:Name="Border" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
FlowDirection="LeftToRight">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition/>
|
||||
|
@ -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
|
||||
|
@ -37,7 +37,9 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:OverflowTextBlock">
|
||||
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="TokenContainer"
|
||||
Background="{TemplateBinding Background}"
|
||||
FlowDirection="LeftToRight">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="12"/>
|
||||
<ColumnDefinition/>
|
||||
@ -96,7 +98,9 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:OverflowTextBlock">
|
||||
<Grid x:Name="TokenContainer" Background="{TemplateBinding Background}">
|
||||
<Grid x:Name="TokenContainer"
|
||||
Background="{TemplateBinding Background}"
|
||||
FlowDirection="LeftToRight">
|
||||
<Grid.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
|
@ -163,7 +163,8 @@
|
||||
<Grid x:Name="ProgrammerOperators"
|
||||
x:Uid="RadixGroup"
|
||||
MaxHeight="244"
|
||||
AutomationProperties.HeadingLevel="Level1">
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
FlowDirection="LeftToRight">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*" MinHeight="0"/>
|
||||
<RowDefinition Height="1*" MinHeight="0"/>
|
||||
|
@ -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"
|
||||
|
@ -1,13 +1,8 @@
|
||||
<UserControl x:Class="CalculatorApp.MemoryListItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:local="using:CalculatorApp"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="using:CalculatorApp.ViewModel"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
x:Name="MemoryListItem"
|
||||
FlowDirection="LeftToRight"
|
||||
|
@ -237,7 +237,6 @@
|
||||
<ClCompile Include="CopyPasteManagerTest.cpp" />
|
||||
<ClCompile Include="CurrencyConverterUnitTests.cpp" />
|
||||
<ClCompile Include="DateCalculatorUnitTests.cpp" />
|
||||
<ClCompile Include="Helper.cpp" />
|
||||
<ClCompile Include="HistoryTests.cpp" />
|
||||
<ClCompile Include="LocalizationServiceUnitTests.cpp" />
|
||||
<ClCompile Include="LocalizationSettingsUnitTests.cpp" />
|
||||
|
@ -30,7 +30,6 @@
|
||||
<ClCompile Include="LocalizationServiceUnitTests.cpp" />
|
||||
<ClCompile Include="RationalTest.cpp" />
|
||||
<ClCompile Include="LocalizationSettingsUnitTests.cpp" />
|
||||
<ClCompile Include="Helper.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DateUtils.h" />
|
||||
|
@ -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;
|
||||
}
|
@ -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<T> ^ vec
|
||||
VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i), __VA_ARGS__);
|
||||
}
|
||||
};
|
||||
|
||||
Platform::String ^ GetStringValue(Platform::String ^ input);
|
||||
|
@ -80,7 +80,7 @@ namespace CalculatorFunctionalTests
|
||||
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
|
||||
int sizeAfterItemAdd = m_historyViewModel->ItemSize;
|
||||
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(historyItem->Expression, expression);
|
||||
VERIFY_ARE_EQUAL(historyItem->Result, L"9");
|
||||
@ -102,7 +102,7 @@ namespace CalculatorFunctionalTests
|
||||
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(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<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::Command5));
|
||||
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(Command::CommandEQU));
|
||||
expression = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF;
|
||||
expression = L"1 + 2 =";
|
||||
output = 3;
|
||||
result = output.ToString();
|
||||
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++)
|
||||
{
|
||||
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<HistoryItemViewModel ^>(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<HistoryItemViewModel ^>(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<int>(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<int>(Command::Command7));
|
||||
m_standardViewModel->SendCommandToCalcManager(static_cast<int>(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();
|
||||
}
|
||||
|
@ -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<HistoryItemViewModel^>(viewModels[0]->HistoryVM->Items->GetAt(0));
|
||||
String ^ expression1 = UtfUtils::LRO + L"1 + 2 =" + UtfUtils::PDF;
|
||||
auto item1 = static_cast<HistoryItemViewModel ^>(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<HistoryItemViewModel^>(viewModels[1]->HistoryVM->Items->GetAt(0));
|
||||
String ^ expression2 = UtfUtils::LRO + L"1 + 2 " + UtfUtils::MUL + L" 3 =" + UtfUtils::PDF;
|
||||
auto item2 = static_cast<HistoryItemViewModel ^>(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<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(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"));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
@ -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<bool>(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<bool>(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<bool>(64, true);
|
||||
@ -776,13 +776,13 @@ namespace CalculatorUnitTests
|
||||
m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(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<int>(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<int>(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<int>(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
|
||||
|
@ -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<UnitConverterMock> mock = make_shared<UnitConverterMock>();
|
||||
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.
|
||||
|
@ -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 <typename TOwner, typename TType>
|
||||
Windows::UI::Xaml::DependencyProperty^ RegisterDependencyProperty(
|
||||
|
Loading…
Reference in New Issue
Block a user