merge with master
This commit is contained in:
@@ -309,7 +309,7 @@ namespace CalculatorEngineTests
|
||||
wstring maxStr{};
|
||||
for (size_t i = 0; i < MAX_STRLEN + 1; i++)
|
||||
{
|
||||
maxStr += L"1";
|
||||
maxStr += L'1';
|
||||
m_calcInput.TryAddDigit(1, 10, false, maxStr, 64, 100);
|
||||
}
|
||||
auto result = m_calcInput.ToString(10);
|
||||
@@ -323,7 +323,7 @@ namespace CalculatorEngineTests
|
||||
bool exponentCapped = false;
|
||||
for (size_t i = 0; i < MAX_STRLEN + 1; i++)
|
||||
{
|
||||
maxStr += L"1";
|
||||
maxStr += L'1';
|
||||
if (!m_calcInput.TryAddDigit(1, 10, false, maxStr, 64, MAX_STRLEN + 25))
|
||||
{
|
||||
exponentCapped = true;
|
||||
|
@@ -43,16 +43,13 @@ namespace CalculatorManagerTest
|
||||
m_isError = isError;
|
||||
}
|
||||
void SetExpressionDisplay(
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& /*commands*/) override
|
||||
_Inout_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& tokens,
|
||||
_Inout_ std::shared_ptr<std::vector<std::shared_ptr<IExpressionCommand>>> const& /*commands*/) override
|
||||
{
|
||||
m_expression.clear();
|
||||
unsigned int nTokens = 0;
|
||||
std::pair<std::wstring, int> currentPair;
|
||||
tokens->GetSize(&nTokens);
|
||||
for (unsigned int i = 0; i < nTokens; ++i)
|
||||
|
||||
for (const auto& currentPair : *tokens)
|
||||
{
|
||||
tokens->GetAt(i, ¤tPair);
|
||||
m_expression += currentPair.first;
|
||||
}
|
||||
}
|
||||
@@ -97,6 +94,10 @@ namespace CalculatorManagerTest
|
||||
m_maxDigitsCalledCount++;
|
||||
}
|
||||
|
||||
void InputChanged() override
|
||||
{
|
||||
}
|
||||
|
||||
int GetMaxDigitsCalledCount()
|
||||
{
|
||||
return m_maxDigitsCalledCount;
|
||||
@@ -179,6 +180,8 @@ namespace CalculatorManagerTest
|
||||
TEST_METHOD(CalculatorManagerTestScientificError);
|
||||
TEST_METHOD(CalculatorManagerTestScientificModeChange);
|
||||
|
||||
TEST_METHOD(CalculatorManagerTestProgrammer);
|
||||
|
||||
TEST_METHOD(CalculatorManagerTestModeChange);
|
||||
|
||||
TEST_METHOD(CalculatorManagerTestMemory);
|
||||
@@ -325,10 +328,10 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands4[] = { Command::Command2, Command::CommandADD, Command::Command3, Command::CommandEQU,
|
||||
Command::Command4, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"7", L"", commands4);
|
||||
TestDriver::Test(L"7", L"4 + 3=", commands4);
|
||||
|
||||
Command commands5[] = { Command::Command4, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"4", L"", commands5);
|
||||
TestDriver::Test(L"4", L"4=", commands5);
|
||||
|
||||
Command commands6[] = { Command::Command2, Command::Command5, Command::Command6, Command::CommandSQRT,
|
||||
Command::CommandSQRT, Command::CommandSQRT, Command::CommandNULL };
|
||||
@@ -336,21 +339,21 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands7[] = { Command::Command3, Command::CommandSUB, Command::Command6, Command::CommandEQU,
|
||||
Command::CommandMUL, Command::Command3, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"-9", L"", commands7);
|
||||
TestDriver::Test(L"-9", L"-3 \x00D7 3=", commands7);
|
||||
|
||||
Command commands8[] = { Command::Command9, Command::CommandMUL, Command::Command6, Command::CommandSUB,
|
||||
Command::CommandCENTR, Command::Command8, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"46", L"", commands8);
|
||||
TestDriver::Test(L"46", L"9 \x00D7 6 - 8=", commands8);
|
||||
|
||||
Command commands9[] = { Command::Command6, Command::CommandMUL, Command::Command6, Command::CommandPERCENT, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"0.36", L"", commands9);
|
||||
TestDriver::Test(L"0.36", L"6 \x00D7 0.06=", commands9);
|
||||
|
||||
Command commands10[] = { Command::Command5, Command::Command0, Command::CommandADD, Command::Command2,
|
||||
Command::Command0, Command::CommandPERCENT, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"60", L"", commands10);
|
||||
TestDriver::Test(L"60", L"50 + 10=", commands10);
|
||||
|
||||
Command commands11[] = { Command::Command4, Command::CommandADD, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"8", L"", commands11);
|
||||
TestDriver::Test(L"8", L"4 + 4=", commands11);
|
||||
|
||||
Command commands12[] = { Command::Command5, Command::CommandADD, Command::CommandMUL, Command::Command3, Command::CommandNULL };
|
||||
TestDriver::Test(L"3", L"5 \x00D7 ", commands12);
|
||||
@@ -361,7 +364,7 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands14[] = { Command::Command5, Command::Command0, Command::CommandADD, Command::Command2,
|
||||
Command::Command0, Command::CommandPERCENT, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"60", L"", commands14);
|
||||
TestDriver::Test(L"60", L"50 + 10=", commands14);
|
||||
|
||||
Command commands15[] = { Command::Command0, Command::CommandDIV, Command::Command0, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"Result is undefined", L"0 \x00F7 ", commands15);
|
||||
@@ -405,10 +408,10 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands4[] = { Command::Command1, Command::CommandADD, Command::Command0, Command::CommandMUL,
|
||||
Command::Command2, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"1", L"", commands4, true, true);
|
||||
TestDriver::Test(L"1", L"1 + 0 \x00D7 2=", commands4, true, true);
|
||||
|
||||
Command commands5[] = { Command::Command4, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"4", L"", commands5, true, true);
|
||||
TestDriver::Test(L"4", L"4=", commands5, true, true);
|
||||
|
||||
Command commands6[] = { Command::Command2, Command::Command5, Command::Command6, Command::CommandSQRT,
|
||||
Command::CommandSQRT, Command::CommandSQRT, Command::CommandNULL };
|
||||
@@ -430,7 +433,7 @@ namespace CalculatorManagerTest
|
||||
TestDriver::Test(L"50.05", L"50 + 1/(20) - ", commands10, true, true);
|
||||
|
||||
Command commands11[] = { Command::Command4, Command::CommandADD, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"8", L"", commands11, true, true);
|
||||
TestDriver::Test(L"8", L"4 + 4=", commands11, true, true);
|
||||
|
||||
Command commands12[] = { Command::Command5, Command::CommandADD, Command::CommandMUL, Command::Command3, Command::CommandNULL };
|
||||
TestDriver::Test(L"3", L"5 \x00D7 ", commands12, true, true);
|
||||
@@ -441,7 +444,7 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands14[] = { Command::Command5, Command::Command0, Command::CommandADD, Command::Command2,
|
||||
Command::Command0, Command::CommandPERCENT, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"60", L"", commands14, true, true);
|
||||
TestDriver::Test(L"60", L"50 + 10=", commands14, true, true);
|
||||
|
||||
Command commands15[] = { Command::Command0, Command::CommandDIV, Command::Command0, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"Result is undefined", L"0 \x00F7 ", commands15, true, true);
|
||||
@@ -495,9 +498,9 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands5[] = { Command::Command8, Command::CommandCUB, Command::CommandNULL };
|
||||
TestDriver::Test(L"512", L"cube(8)", commands5, true, true);
|
||||
/*
|
||||
Command commands6[] = { Command::Command8, Command::CommandCUB, Command::CommandCUBEROOT, Command::CommandNULL };
|
||||
TestDriver::Test(L"8", L"cuberoot(cube(8))", commands6, true, true);*/
|
||||
|
||||
Command commands6[] = { Command::Command8, Command::CommandCUB, Command::CommandCUBEROOT, Command::CommandNULL };
|
||||
TestDriver::Test(L"8", L"cuberoot(cube(8))", commands6, true, true);
|
||||
|
||||
Command commands7[] = { Command::Command1, Command::Command0, Command::CommandLOG, Command::CommandNULL };
|
||||
TestDriver::Test(L"1", L"log(10)", commands7, true, true);
|
||||
@@ -552,6 +555,66 @@ namespace CalculatorManagerTest
|
||||
Command commands22[] = { Command::Command1, Command::Command0, Command::CommandPWR, Command::Command1, Command::CommandPNT, Command::Command2,
|
||||
Command::Command3, Command::Command4, Command::Command5, Command::Command6, Command::CommandADD, Command::CommandNULL };
|
||||
TestDriver::Test(L"17.161687912241792074207286679393", L"10 ^ 1.23456 + ", commands22, true, true);
|
||||
|
||||
Command commands23[] = { Command::Command1, Command::CommandSEC, Command::CommandNULL };
|
||||
TestDriver::Test(L"1.0001523280439076654284264342126", L"sec\x2080(1)", commands23, true, true);
|
||||
|
||||
Command commands24[] = { Command::Command1, Command::CommandCSC, Command::CommandNULL };
|
||||
TestDriver::Test(L"57.298688498550183476612683735174", L"csc\x2080(1)", commands24, true, true);
|
||||
|
||||
Command commands25[] = { Command::Command1, Command::CommandCOT, Command::CommandNULL };
|
||||
TestDriver::Test(L"57.289961630759424687278147537113", L"cot\x2080(1)", commands25, true, true);
|
||||
|
||||
Command commands26[] = { Command::Command1, Command::CommandASEC, Command::CommandNULL };
|
||||
TestDriver::Test(L"0", L"sec\x2080\x207B\x00B9(1)", commands26, true, true);
|
||||
|
||||
Command commands27[] = { Command::Command1, Command::CommandACSC, Command::CommandNULL };
|
||||
TestDriver::Test(L"90", L"csc\x2080\x207B\x00B9(1)", commands27, true, true);
|
||||
|
||||
Command commands28[] = { Command::Command1, Command::CommandACOT, Command::CommandNULL };
|
||||
TestDriver::Test(L"45", L"cot\x2080\x207B\x00B9(1)", commands28, true, true);
|
||||
|
||||
Command commands29[] = { Command::Command1, Command::CommandSECH, Command::CommandNULL };
|
||||
TestDriver::Test(L"0.64805427366388539957497735322615", L"sech(1)", commands29, true, true);
|
||||
|
||||
Command commands30[] = { Command::Command1, Command::CommandCSCH, Command::CommandNULL };
|
||||
TestDriver::Test(L"0.85091812823932154513384276328718", L"csch(1)", commands30, true, true);
|
||||
|
||||
Command commands31[] = { Command::Command1, Command::CommandCOTH, Command::CommandNULL };
|
||||
TestDriver::Test(L"1.3130352854993313036361612469308", L"coth(1)", commands31, true, true);
|
||||
|
||||
Command commands32[] = { Command::Command1, Command::CommandASECH, Command::CommandNULL };
|
||||
TestDriver::Test(L"0", L"sech\x207B\x00B9(1)", commands32, true, true);
|
||||
|
||||
Command commands33[] = { Command::Command1, Command::CommandACSCH, Command::CommandNULL };
|
||||
TestDriver::Test(L"0.88137358701954302523260932497979", L"csch\x207B\x00B9(1)", commands33, true, true);
|
||||
|
||||
Command commands34[] = { Command::Command2, Command::CommandACOTH, Command::CommandNULL };
|
||||
TestDriver::Test(L"0.54930614433405484569762261846126", L"coth\x207B\x00B9(2)", commands34, true, true);
|
||||
|
||||
Command commands35[] = { Command::Command8, Command::CommandPOW2, Command::CommandNULL };
|
||||
TestDriver::Test(L"256", L"2^(8)", commands35);
|
||||
|
||||
Command commands36[] = { Command::CommandRand, Command::CommandCeil, Command::CommandNULL };
|
||||
TestDriver::Test(L"1", L"N/A", commands36);
|
||||
|
||||
Command commands37[] = { Command::CommandRand, Command::CommandFloor, Command::CommandNULL };
|
||||
TestDriver::Test(L"0", L"N/A", commands37);
|
||||
|
||||
Command commands38[] = { Command::CommandRand, Command::CommandSIGN, Command::CommandCeil, Command::CommandNULL };
|
||||
TestDriver::Test(L"0", L"N/A", commands38);
|
||||
|
||||
Command commands39[] = { Command::CommandRand, Command::CommandSIGN, Command::CommandFloor, Command::CommandNULL };
|
||||
TestDriver::Test(L"-1", L"N/A", commands39);
|
||||
|
||||
Command commands40[] = { Command::Command3, Command::CommandPNT, Command::Command8, Command::CommandFloor, Command::CommandNULL };
|
||||
TestDriver::Test(L"3", L"floor(3.8)", commands40);
|
||||
|
||||
Command commands41[] = { Command::Command3, Command::CommandPNT, Command::Command8, Command::CommandCeil, Command::CommandNULL };
|
||||
TestDriver::Test(L"4", L"ceil(3.8)", commands41);
|
||||
|
||||
Command commands42[] = { Command::Command3, Command::CommandLogBaseX, Command::Command5, Command::CommandADD, Command::CommandNULL };
|
||||
TestDriver::Test(L"1.464973520717927", L"3 base log 5 + ", commands42);
|
||||
}
|
||||
|
||||
void CalculatorManagerTest::CalculatorManagerTestScientificParenthesis()
|
||||
@@ -576,7 +639,7 @@ namespace CalculatorManagerTest
|
||||
|
||||
Command commands5[] = { Command::Command2, Command::CommandOPENP, Command::Command2, Command::CommandCLOSEP,
|
||||
Command::CommandADD, Command::CommandEQU, Command::CommandNULL };
|
||||
TestDriver::Test(L"4", L"", commands5, true, true);
|
||||
TestDriver::Test(L"4", L"(2) + 2=", commands5, true, true);
|
||||
}
|
||||
|
||||
void CalculatorManagerTest::CalculatorManagerTestScientificError()
|
||||
@@ -651,6 +714,41 @@ namespace CalculatorManagerTest
|
||||
TestDriver::Test(L"0", L"", commands8, true, false);
|
||||
}
|
||||
|
||||
void CalculatorManagerTest::CalculatorManagerTestProgrammer()
|
||||
{
|
||||
Command commands1[] = { Command::ModeProgrammer, Command::Command5, Command::Command3, Command::CommandNand,
|
||||
Command::Command8, Command::Command3, Command::CommandAnd, Command::CommandNULL };
|
||||
TestDriver::Test(L"-18", L"53 NAND 83 AND ", commands1, true, false);
|
||||
|
||||
Command commands2[] = { Command::ModeProgrammer, Command::Command5, Command::Command3, Command::CommandNor,
|
||||
Command::Command8, Command::Command3, Command::CommandAnd, Command::CommandNULL };
|
||||
TestDriver::Test(L"-120", L"53 NOR 83 AND ", commands2, true, false);
|
||||
|
||||
Command commands3[] = { Command::ModeProgrammer, Command::Command5, Command::CommandLSHF,
|
||||
Command::Command1, Command::CommandAnd, Command::CommandNULL };
|
||||
TestDriver::Test(L"10", L"5 Lsh 1 AND ", commands3, true, false);
|
||||
|
||||
Command commands5[] = { Command::ModeProgrammer, Command::Command5, Command::CommandRSHFL,
|
||||
Command::Command1, Command::CommandAnd, Command::CommandNULL };
|
||||
TestDriver::Test(L"2", L"5 Rsh 1 AND ", commands5, true, false);
|
||||
|
||||
Command commands6[] = { Command::ModeProgrammer, Command::CommandBINPOS63, Command::CommandRSHF,
|
||||
Command::Command5, Command::Command6, Command::CommandAnd, Command::CommandNULL };
|
||||
TestDriver::Test(L"-128", L"-9223372036854775808 Rsh 56 AND ", commands6, true, false);
|
||||
|
||||
Command commands7[] = { Command::ModeProgrammer, Command::Command1, Command::CommandROL, Command::CommandNULL };
|
||||
TestDriver::Test(L"2", L"RoL(1)", commands7, true, false);
|
||||
|
||||
Command commands8[] = { Command::ModeProgrammer, Command::Command1, Command::CommandROR, Command::CommandNULL };
|
||||
TestDriver::Test(L"-9,223,372,036,854,775,808", L"RoR(1)", commands8, true, false);
|
||||
|
||||
Command commands9[] = { Command::ModeProgrammer, Command::Command1, Command::CommandRORC, Command::CommandNULL };
|
||||
TestDriver::Test(L"0", L"RoR(1)", commands9, true, false);
|
||||
|
||||
Command commands10[] = { Command::ModeProgrammer, Command::Command1, Command::CommandRORC, Command::CommandRORC, Command::CommandNULL };
|
||||
TestDriver::Test(L"-9,223,372,036,854,775,808", L"RoR(RoR(1))", commands10, true, false);
|
||||
}
|
||||
|
||||
void CalculatorManagerTest::CalculatorManagerTestMemory()
|
||||
{
|
||||
Command scientificCalculatorTest52[] = { Command::Command1, Command::CommandSTORE, Command::CommandNULL };
|
||||
|
@@ -207,12 +207,10 @@
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AsyncHelper.h" />
|
||||
<ClInclude Include="DateUtils.h" />
|
||||
<ClInclude Include="Helpers.h" />
|
||||
<ClInclude Include="Mocks\CurrencyHttpClient.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="UnitConverterViewModelUnitTests.h" />
|
||||
<ClInclude Include="UnitTestApp.xaml.h">
|
||||
<DependentUpon>UnitTestApp.xaml</DependentUpon>
|
||||
@@ -238,7 +236,6 @@
|
||||
<Image Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AsyncHelper.cpp" />
|
||||
<ClCompile Include="CalcEngineTests.cpp" />
|
||||
<ClCompile Include="CalcInputTest.cpp" />
|
||||
<ClCompile Include="CalculatorManagerTest.cpp" />
|
||||
@@ -248,7 +245,6 @@
|
||||
<ClCompile Include="HistoryTests.cpp" />
|
||||
<ClCompile Include="LocalizationServiceUnitTests.cpp" />
|
||||
<ClCompile Include="Mocks\CurrencyHttpClient.cpp" />
|
||||
<ClCompile Include="Module.cpp" />
|
||||
<ClCompile Include="MultiWindowUnitTests.cpp" />
|
||||
<ClCompile Include="NavCategoryUnitTests.cpp" />
|
||||
<ClCompile Include="RationalTest.cpp" />
|
||||
@@ -272,7 +268,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<SDKReference Include="CppUnitTestFramework.Universal, Version=$(UnitTestPlatformVersion)" />
|
||||
<SDKReference Include="Microsoft.VCLibs.Desktop, Version=14.0" />
|
||||
<SDKReference Include="TestPlatform.Universal, Version=$(UnitTestPlatformVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -288,9 +283,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
</PRIResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CalculatorUnitTests.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalcManager\CalcManager.vcxproj">
|
||||
<Project>{311e866d-8b93-4609-a691-265941fee101}</Project>
|
||||
|
@@ -9,7 +9,6 @@
|
||||
<PRIResource Include="Test.resw" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AsyncHelper.cpp" />
|
||||
<ClCompile Include="CalcEngineTests.cpp" />
|
||||
<ClCompile Include="CalcInputTest.cpp" />
|
||||
<ClCompile Include="CalculatorManagerTest.cpp" />
|
||||
@@ -17,7 +16,6 @@
|
||||
<ClCompile Include="CurrencyConverterUnitTests.cpp" />
|
||||
<ClCompile Include="DateCalculatorUnitTests.cpp" />
|
||||
<ClCompile Include="HistoryTests.cpp" />
|
||||
<ClCompile Include="Module.cpp" />
|
||||
<ClCompile Include="MultiWindowUnitTests.cpp" />
|
||||
<ClCompile Include="NavCategoryUnitTests.cpp" />
|
||||
<ClCompile Include="StandardViewModelUnitTests.cpp" />
|
||||
@@ -33,20 +31,15 @@
|
||||
<ClCompile Include="RationalTest.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AsyncHelper.h" />
|
||||
<ClInclude Include="DateUtils.h" />
|
||||
<ClInclude Include="Helpers.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="UnitConverterViewModelUnitTests.h" />
|
||||
<ClInclude Include="UnitTestApp.xaml.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="Mocks\CurrencyHttpClient.h">
|
||||
<Filter>Mocks</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="CalculatorUnitTests.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Xml Include="UnitTestApp.rd.xml" />
|
||||
</ItemGroup>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -27,8 +27,6 @@ namespace DateCalculationUnitTests
|
||||
const int c_subtractCases = 3;
|
||||
const int c_dateDiff = 14;
|
||||
|
||||
DateCalculationEngine m_DateCalcEngine(CalendarIdentifiers::Gregorian);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SYSTEMTIME startDate;
|
||||
@@ -45,10 +43,382 @@ namespace DateCalculationUnitTests
|
||||
DateTimeTestCase datetimeSubtractCase[c_subtractCases];
|
||||
|
||||
// Test Class
|
||||
TEST_CLASS(DateCalculatorUnitTests){ public: TEST_CLASS_INITIALIZE(TestClassSetup){ /* Test Case Data */
|
||||
TEST_CLASS(DateCalculatorUnitTests)
|
||||
{
|
||||
static DateCalculationEngine ^ m_DateCalcEngine;
|
||||
|
||||
// Dates - DD.MM.YYYY
|
||||
/*31.12.9999*/ date[0].wYear = 9999;
|
||||
public:
|
||||
TEST_CLASS_INITIALIZE(TestClassSetup)
|
||||
{
|
||||
m_DateCalcEngine = ref new DateCalculationEngine(CalendarIdentifiers::Gregorian);
|
||||
|
||||
/* Test Case Data */
|
||||
|
||||
// Dates - DD.MM.YYYY
|
||||
/*31.12.9999*/
|
||||
date[0].wYear = 9999;
|
||||
date[0].wMonth = 12;
|
||||
date[0].wDayOfWeek = 5;
|
||||
date[0].wDay = 31;
|
||||
date[0].wHour = 0;
|
||||
date[0].wMinute = 0;
|
||||
date[0].wSecond = 0;
|
||||
date[0].wMilliseconds = 0;
|
||||
/*30.12.9999*/ date[1].wYear = 9999;
|
||||
date[1].wMonth = 12;
|
||||
date[1].wDayOfWeek = 4;
|
||||
date[1].wDay = 30;
|
||||
date[1].wHour = 0;
|
||||
date[1].wMinute = 0;
|
||||
date[1].wSecond = 0;
|
||||
date[1].wMilliseconds = 0;
|
||||
/*31.12.9998*/ date[2].wYear = 9998;
|
||||
date[2].wMonth = 12;
|
||||
date[2].wDayOfWeek = 4;
|
||||
date[2].wDay = 31;
|
||||
date[2].wHour = 0;
|
||||
date[2].wMinute = 0;
|
||||
date[2].wSecond = 0;
|
||||
date[2].wMilliseconds = 0;
|
||||
/*01.01.1601*/ date[3].wYear = 1601;
|
||||
date[3].wMonth = 1;
|
||||
date[3].wDayOfWeek = 1;
|
||||
date[3].wDay = 1;
|
||||
date[3].wHour = 0;
|
||||
date[3].wMinute = 0;
|
||||
date[3].wSecond = 0;
|
||||
date[3].wMilliseconds = 0;
|
||||
/*02.01.1601*/ date[4].wYear = 1601;
|
||||
date[4].wMonth = 1;
|
||||
date[4].wDayOfWeek = 2;
|
||||
date[4].wDay = 2;
|
||||
date[4].wHour = 0;
|
||||
date[4].wMinute = 0;
|
||||
date[4].wSecond = 0;
|
||||
date[4].wMilliseconds = 0;
|
||||
/*10.05.2008*/ date[5].wYear = 2008;
|
||||
date[5].wMonth = 5;
|
||||
date[5].wDayOfWeek = 6;
|
||||
date[5].wDay = 10;
|
||||
date[5].wHour = 0;
|
||||
date[5].wMinute = 0;
|
||||
date[5].wSecond = 0;
|
||||
date[5].wMilliseconds = 0;
|
||||
/*10.03.2008*/ date[6].wYear = 2008;
|
||||
date[6].wMonth = 3;
|
||||
date[6].wDayOfWeek = 1;
|
||||
date[6].wDay = 10;
|
||||
date[6].wHour = 0;
|
||||
date[6].wMinute = 0;
|
||||
date[6].wSecond = 0;
|
||||
date[6].wMilliseconds = 0;
|
||||
/*29.02.2008*/ date[7].wYear = 2008;
|
||||
date[7].wMonth = 2;
|
||||
date[7].wDayOfWeek = 5;
|
||||
date[7].wDay = 29;
|
||||
date[7].wHour = 0;
|
||||
date[7].wMinute = 0;
|
||||
date[7].wSecond = 0;
|
||||
date[7].wMilliseconds = 0;
|
||||
/*28.02.2007*/ date[8].wYear = 2007;
|
||||
date[8].wMonth = 2;
|
||||
date[8].wDayOfWeek = 3;
|
||||
date[8].wDay = 28;
|
||||
date[8].wHour = 0;
|
||||
date[8].wMinute = 0;
|
||||
date[8].wSecond = 0;
|
||||
date[8].wMilliseconds = 0;
|
||||
/*10.03.2007*/ date[9].wYear = 2007;
|
||||
date[9].wMonth = 3;
|
||||
date[9].wDayOfWeek = 6;
|
||||
date[9].wDay = 10;
|
||||
date[9].wHour = 0;
|
||||
date[9].wMinute = 0;
|
||||
date[9].wSecond = 0;
|
||||
date[9].wMilliseconds = 0;
|
||||
/*10.05.2007*/ date[10].wYear = 2007;
|
||||
date[10].wMonth = 5;
|
||||
date[10].wDayOfWeek = 4;
|
||||
date[10].wDay = 10;
|
||||
date[10].wHour = 0;
|
||||
date[10].wMinute = 0;
|
||||
date[10].wSecond = 0;
|
||||
date[10].wMilliseconds = 0;
|
||||
/*29.01.2008*/ date[11].wYear = 2008;
|
||||
date[11].wMonth = 1;
|
||||
date[11].wDayOfWeek = 2;
|
||||
date[11].wDay = 29;
|
||||
date[11].wHour = 0;
|
||||
date[11].wMinute = 0;
|
||||
date[11].wSecond = 0;
|
||||
date[11].wMilliseconds = 0;
|
||||
/*28.01.2007*/ date[12].wYear = 2007;
|
||||
date[12].wMonth = 1;
|
||||
date[12].wDayOfWeek = 0;
|
||||
date[12].wDay = 28;
|
||||
date[12].wHour = 0;
|
||||
date[12].wMinute = 0;
|
||||
date[12].wSecond = 0;
|
||||
date[12].wMilliseconds = 0;
|
||||
/*31.01.2008*/ date[13].wYear = 2008;
|
||||
date[13].wMonth = 1;
|
||||
date[13].wDayOfWeek = 4;
|
||||
date[13].wDay = 31;
|
||||
date[13].wHour = 0;
|
||||
date[13].wMinute = 0;
|
||||
date[13].wSecond = 0;
|
||||
date[13].wMilliseconds = 0;
|
||||
/*31.03.2008*/ date[14].wYear = 2008;
|
||||
date[14].wMonth = 3;
|
||||
date[14].wDayOfWeek = 1;
|
||||
date[14].wDay = 31;
|
||||
date[14].wHour = 0;
|
||||
date[14].wMinute = 0;
|
||||
date[14].wSecond = 0;
|
||||
date[14].wMilliseconds = 0;
|
||||
|
||||
// Date Differences
|
||||
dateDifference[0].year = 1;
|
||||
dateDifference[0].month = 1;
|
||||
dateDifference[1].month = 1;
|
||||
dateDifference[1].day = 10;
|
||||
dateDifference[2].day = 2;
|
||||
/*date[2]-[0]*/ dateDifference[3].week = 52;
|
||||
dateDifference[3].day = 1;
|
||||
/*date[2]-[0]*/ dateDifference[4].year = 1;
|
||||
dateDifference[5].day = 365;
|
||||
dateDifference[6].month = 1;
|
||||
dateDifference[7].month = 1;
|
||||
dateDifference[7].day = 2;
|
||||
dateDifference[8].day = 31;
|
||||
dateDifference[9].month = 11;
|
||||
dateDifference[9].day = 1;
|
||||
dateDifference[10].year = 8398;
|
||||
dateDifference[10].month = 11;
|
||||
dateDifference[10].day = 30;
|
||||
dateDifference[11].year = 2008;
|
||||
dateDifference[12].year = 7991;
|
||||
dateDifference[12].month = 11;
|
||||
dateDifference[13].week = 416998;
|
||||
dateDifference[13].day = 1;
|
||||
|
||||
/* Test Cases */
|
||||
|
||||
// Date Difference test cases
|
||||
datetimeDifftest[0].startDate = date[0];
|
||||
datetimeDifftest[0].endDate = date[3];
|
||||
datetimeDifftest[0].dateDiff = dateDifference[10];
|
||||
datetimeDifftest[1].startDate = date[0];
|
||||
datetimeDifftest[1].endDate = date[2];
|
||||
datetimeDifftest[1].dateDiff = dateDifference[5];
|
||||
datetimeDifftest[2].startDate = date[0];
|
||||
datetimeDifftest[2].endDate = date[2];
|
||||
datetimeDifftest[2].dateDiff = dateDifference[4];
|
||||
datetimeDifftest[3].startDate = date[0];
|
||||
datetimeDifftest[3].endDate = date[2];
|
||||
datetimeDifftest[3].dateDiff = dateDifference[3];
|
||||
datetimeDifftest[4].startDate = date[14];
|
||||
datetimeDifftest[4].endDate = date[7];
|
||||
datetimeDifftest[4].dateDiff = dateDifference[7];
|
||||
datetimeDifftest[5].startDate = date[14];
|
||||
datetimeDifftest[5].endDate = date[7];
|
||||
datetimeDifftest[5].dateDiff = dateDifference[8];
|
||||
datetimeDifftest[6].startDate = date[11];
|
||||
datetimeDifftest[6].endDate = date[8];
|
||||
datetimeDifftest[6].dateDiff = dateDifference[9];
|
||||
datetimeDifftest[7].startDate = date[13];
|
||||
datetimeDifftest[7].endDate = date[0];
|
||||
datetimeDifftest[7].dateDiff = dateDifference[12];
|
||||
datetimeDifftest[8].startDate = date[13];
|
||||
datetimeDifftest[8].endDate = date[0];
|
||||
datetimeDifftest[8].dateDiff = dateDifference[13];
|
||||
|
||||
// Date Add Out of Bound test cases (Negative tests)
|
||||
/*OutofBound*/ datetimeBoundAdd[0].startDate = date[1];
|
||||
datetimeBoundAdd[0].endDate = date[0];
|
||||
datetimeBoundAdd[0].dateDiff = dateDifference[2]; // on Add date[0] not used
|
||||
/*OutofBound*/ datetimeBoundAdd[1].startDate = date[2];
|
||||
datetimeBoundAdd[1].endDate = date[0];
|
||||
datetimeBoundAdd[1].dateDiff = dateDifference[11]; // on Add date[0] not used
|
||||
|
||||
// Date Subtract Out of Bound test cases (Negative tests)
|
||||
/*OutofBound*/ datetimeBoundSubtract[0].startDate = date[3];
|
||||
datetimeBoundSubtract[0].endDate = date[0];
|
||||
datetimeBoundSubtract[0].dateDiff = dateDifference[2]; // on subtract date[0] not used
|
||||
/*OutofBound*/ datetimeBoundSubtract[1].startDate = date[14];
|
||||
datetimeBoundSubtract[1].endDate = date[0];
|
||||
datetimeBoundSubtract[1].dateDiff = dateDifference[11]; // on subtract date[0] not used
|
||||
|
||||
// Date Add test cases (Positive tests)
|
||||
datetimeAddCase[0].startDate = date[13];
|
||||
datetimeAddCase[0].endDate = date[7];
|
||||
datetimeAddCase[0].dateDiff = dateDifference[6]; // add
|
||||
datetimeAddCase[1].startDate = date[14];
|
||||
datetimeAddCase[1].endDate = date[5];
|
||||
datetimeAddCase[1].dateDiff = dateDifference[1]; // add
|
||||
datetimeAddCase[2].startDate = date[13];
|
||||
datetimeAddCase[2].endDate = date[6];
|
||||
datetimeAddCase[2].dateDiff = dateDifference[1]; // add
|
||||
|
||||
// Date Subtract test cases (Positive tests)
|
||||
datetimeSubtractCase[0].startDate = date[14];
|
||||
datetimeSubtractCase[0].endDate = date[7];
|
||||
datetimeSubtractCase[0].dateDiff = dateDifference[6]; // subtract
|
||||
datetimeSubtractCase[1].startDate = date[6];
|
||||
datetimeSubtractCase[1].endDate = date[11];
|
||||
datetimeSubtractCase[1].dateDiff = dateDifference[1]; // subtract
|
||||
datetimeSubtractCase[2].startDate = date[9];
|
||||
datetimeSubtractCase[2].endDate = date[12];
|
||||
datetimeSubtractCase[2].dateDiff = dateDifference[1]; // subtract
|
||||
}
|
||||
|
||||
/* Duration Between Two Date Tests -- Timediff obtained after calculation should be checked to be identical */
|
||||
TEST_METHOD(TestDateDiff)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_diffTestCase; testIndex++)
|
||||
//{
|
||||
// DateDifference diff;
|
||||
// DateUnit dateOutputFormat;
|
||||
|
||||
// switch (testIndex)
|
||||
// {
|
||||
// case 0:
|
||||
// case 2:
|
||||
// dateOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 1:
|
||||
// dateOutputFormat = DateUnit::Day;
|
||||
// break;
|
||||
// case 3:
|
||||
// case 8:
|
||||
// dateOutputFormat = DateUnit::Week | DateUnit::Day;
|
||||
// break;
|
||||
// case 7:
|
||||
// dateOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 4:
|
||||
// case 6:
|
||||
// dateOutputFormat = DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 5:
|
||||
// dateOutputFormat = DateUnit::Day;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// // Calculate the difference
|
||||
// m_DateCalcEngine->TryGetDateDifference(DateUtils::SystemTimeToDateTime(datetimeDifftest[testIndex].startDate),
|
||||
// DateUtils::SystemTimeToDateTime(datetimeDifftest[testIndex].endDate), dateOutputFormat, &diff);
|
||||
|
||||
// // Assert for the result
|
||||
// bool areIdentical = true;
|
||||
// if (diff.year != datetimeDifftest[testIndex].dateDiff.year ||
|
||||
// diff.month != datetimeDifftest[testIndex].dateDiff.month ||
|
||||
// diff.week != datetimeDifftest[testIndex].dateDiff.week ||
|
||||
// diff.day != datetimeDifftest[testIndex].dateDiff.day)
|
||||
// {
|
||||
// areIdentical = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(areIdentical);
|
||||
//}
|
||||
}
|
||||
|
||||
/*Add Out of bound Tests*/
|
||||
TEST_METHOD(TestAddOob)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex< c_numAddOobDate; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Add Duration
|
||||
// bool isValid = m_DateCalcEngine->AddDuration(DateUtils::SystemTimeToDateTime(datetimeBoundAdd[testIndex].startDate),
|
||||
// datetimeBoundAdd[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // Assert for the result
|
||||
// VERIFY_IS_FALSE(isValid);
|
||||
//}
|
||||
}
|
||||
|
||||
/*Subtract Out of bound Tests*/
|
||||
TEST_METHOD(TestSubtractOob)
|
||||
{
|
||||
for (int testIndex = 0; testIndex < c_numSubtractOobDate; testIndex++)
|
||||
{
|
||||
// Subtract Duration
|
||||
auto endDate = m_DateCalcEngine->SubtractDuration(
|
||||
DateUtils::SystemTimeToDateTime(datetimeBoundSubtract[testIndex].startDate), datetimeBoundSubtract[testIndex].dateDiff);
|
||||
|
||||
// Assert for the result
|
||||
VERIFY_IS_NULL(endDate);
|
||||
}
|
||||
}
|
||||
|
||||
// Add Tests
|
||||
TEST_METHOD(TestAddition)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_addCases; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Add Duration
|
||||
// bool isValid = m_DateCalcEngine->AddDuration(DateUtils::SystemTimeToDateTime(datetimeAddCase[testIndex].startDate),
|
||||
// datetimeAddCase[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // Assert for the result
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
|
||||
// SYSTEMTIME systemTime = DateUtils::DateTimeToSystemTime(endDate);
|
||||
// if (systemTime.wYear != datetimeAddCase[testIndex].endDate.wYear ||
|
||||
// systemTime.wMonth != datetimeAddCase[testIndex].endDate.wMonth ||
|
||||
// systemTime.wDay != datetimeAddCase[testIndex].endDate.wDay ||
|
||||
// systemTime.wDayOfWeek != datetimeAddCase[testIndex].endDate.wDayOfWeek)
|
||||
// {
|
||||
// isValid = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
//}
|
||||
}
|
||||
|
||||
// Subtract Tests
|
||||
TEST_METHOD(TestSubtraction)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_subtractCases; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Subtract Duration
|
||||
// bool isValid = m_DateCalcEngine->SubtractDuration(DateUtils::SystemTimeToDateTime(datetimeSubtractCase[testIndex].startDate),
|
||||
// datetimeSubtractCase[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // assert for the result
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
|
||||
// SYSTEMTIME systemTime = DateUtils::DateTimeToSystemTime(endDate);
|
||||
// if (systemTime.wYear != datetimeSubtractCase[testIndex].endDate.wYear ||
|
||||
// systemTime.wMonth != datetimeSubtractCase[testIndex].endDate.wMonth ||
|
||||
// systemTime.wDay != datetimeSubtractCase[testIndex].endDate.wDay ||
|
||||
// systemTime.wDayOfWeek != datetimeSubtractCase[testIndex].endDate.wDayOfWeek)
|
||||
// {
|
||||
// isValid = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
//}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS(DateCalculatorViewModelTests){ public: TEST_CLASS_INITIALIZE(TestClassSetup){ /* Test Case Data */
|
||||
// Dates - DD.MM.YYYY
|
||||
/*31.12.9999*/ date[0].wYear = 9999;
|
||||
date[0].wMonth = 12;
|
||||
date[0].wDayOfWeek = 5;
|
||||
date[0].wDay = 31;
|
||||
@@ -264,374 +634,6 @@ namespace DateCalculationUnitTests
|
||||
datetimeSubtractCase[2].dateDiff = dateDifference[1]; // subtract
|
||||
}
|
||||
|
||||
/* Duration Between Two Date Tests -- Timediff obtained after calculation should be checked to be identical */
|
||||
TEST_METHOD(TestDateDiff)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_diffTestCase; testIndex++)
|
||||
//{
|
||||
// DateDifference diff;
|
||||
// DateUnit dateOutputFormat;
|
||||
|
||||
// switch (testIndex)
|
||||
// {
|
||||
// case 0:
|
||||
// case 2:
|
||||
// dateOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 1:
|
||||
// dateOutputFormat = DateUnit::Day;
|
||||
// break;
|
||||
// case 3:
|
||||
// case 8:
|
||||
// dateOutputFormat = DateUnit::Week | DateUnit::Day;
|
||||
// break;
|
||||
// case 7:
|
||||
// dateOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 4:
|
||||
// case 6:
|
||||
// dateOutputFormat = DateUnit::Month | DateUnit::Day;
|
||||
// break;
|
||||
// case 5:
|
||||
// dateOutputFormat = DateUnit::Day;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// // Calculate the difference
|
||||
// m_DateCalcEngine.TryGetDateDifference(DateUtils::SystemTimeToDateTime(datetimeDifftest[testIndex].startDate),
|
||||
// DateUtils::SystemTimeToDateTime(datetimeDifftest[testIndex].endDate), dateOutputFormat, &diff);
|
||||
|
||||
// // Assert for the result
|
||||
// bool areIdentical = true;
|
||||
// if (diff.year != datetimeDifftest[testIndex].dateDiff.year ||
|
||||
// diff.month != datetimeDifftest[testIndex].dateDiff.month ||
|
||||
// diff.week != datetimeDifftest[testIndex].dateDiff.week ||
|
||||
// diff.day != datetimeDifftest[testIndex].dateDiff.day)
|
||||
// {
|
||||
// areIdentical = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(areIdentical);
|
||||
//}
|
||||
}
|
||||
|
||||
/*Add Out of bound Tests*/
|
||||
TEST_METHOD(TestAddOob)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex< c_numAddOobDate; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Add Duration
|
||||
// bool isValid = m_DateCalcEngine.AddDuration(DateUtils::SystemTimeToDateTime(datetimeBoundAdd[testIndex].startDate),
|
||||
// datetimeBoundAdd[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // Assert for the result
|
||||
// VERIFY_IS_FALSE(isValid);
|
||||
//}
|
||||
}
|
||||
|
||||
/*Subtract Out of bound Tests*/
|
||||
TEST_METHOD(TestSubtractOob)
|
||||
{
|
||||
for (int testIndex = 0; testIndex < c_numSubtractOobDate; testIndex++)
|
||||
{
|
||||
DateTime endDate;
|
||||
|
||||
// Subtract Duration
|
||||
bool isValid = m_DateCalcEngine.SubtractDuration(
|
||||
DateUtils::SystemTimeToDateTime(datetimeBoundSubtract[testIndex].startDate), datetimeBoundSubtract[testIndex].dateDiff, &endDate);
|
||||
|
||||
// Assert for the result
|
||||
VERIFY_IS_FALSE(isValid);
|
||||
}
|
||||
}
|
||||
|
||||
// Add Tests
|
||||
TEST_METHOD(TestAddition)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_addCases; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Add Duration
|
||||
// bool isValid = m_DateCalcEngine.AddDuration(DateUtils::SystemTimeToDateTime(datetimeAddCase[testIndex].startDate),
|
||||
// datetimeAddCase[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // Assert for the result
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
|
||||
// SYSTEMTIME systemTime = DateUtils::DateTimeToSystemTime(endDate);
|
||||
// if (systemTime.wYear != datetimeAddCase[testIndex].endDate.wYear ||
|
||||
// systemTime.wMonth != datetimeAddCase[testIndex].endDate.wMonth ||
|
||||
// systemTime.wDay != datetimeAddCase[testIndex].endDate.wDay ||
|
||||
// systemTime.wDayOfWeek != datetimeAddCase[testIndex].endDate.wDayOfWeek)
|
||||
// {
|
||||
// isValid = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
//}
|
||||
}
|
||||
|
||||
// Subtract Tests
|
||||
TEST_METHOD(TestSubtraction)
|
||||
{
|
||||
// TODO - MSFT 10331900, fix this test
|
||||
|
||||
// for (int testIndex = 0; testIndex < c_subtractCases; testIndex++)
|
||||
//{
|
||||
// DateTime endDate;
|
||||
|
||||
// // Subtract Duration
|
||||
// bool isValid = m_DateCalcEngine.SubtractDuration(DateUtils::SystemTimeToDateTime(datetimeSubtractCase[testIndex].startDate),
|
||||
// datetimeSubtractCase[testIndex].dateDiff, &endDate);
|
||||
|
||||
// // assert for the result
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
|
||||
// SYSTEMTIME systemTime = DateUtils::DateTimeToSystemTime(endDate);
|
||||
// if (systemTime.wYear != datetimeSubtractCase[testIndex].endDate.wYear ||
|
||||
// systemTime.wMonth != datetimeSubtractCase[testIndex].endDate.wMonth ||
|
||||
// systemTime.wDay != datetimeSubtractCase[testIndex].endDate.wDay ||
|
||||
// systemTime.wDayOfWeek != datetimeSubtractCase[testIndex].endDate.wDayOfWeek)
|
||||
// {
|
||||
// isValid = false;
|
||||
// }
|
||||
|
||||
// VERIFY_IS_TRUE(isValid);
|
||||
//}
|
||||
}
|
||||
|
||||
private:
|
||||
}
|
||||
;
|
||||
|
||||
TEST_CLASS(DateCalculatorViewModelTests){ public: TEST_CLASS_INITIALIZE(TestClassSetup){ /* Test Case Data */
|
||||
|
||||
// Dates - DD.MM.YYYY
|
||||
/*31.12.9999*/ date[0].wYear = 9999;
|
||||
date[0].wMonth = 12;
|
||||
date[0].wDayOfWeek = 5;
|
||||
date[0].wDay = 31;
|
||||
date[0].wHour = 0;
|
||||
date[0].wMinute = 0;
|
||||
date[0].wSecond = 0;
|
||||
date[0].wMilliseconds = 0;
|
||||
/*30.12.9999*/ date[1].wYear = 9999;
|
||||
date[1].wMonth = 12;
|
||||
date[1].wDayOfWeek = 4;
|
||||
date[1].wDay = 30;
|
||||
date[1].wHour = 0;
|
||||
date[1].wMinute = 0;
|
||||
date[1].wSecond = 0;
|
||||
date[1].wMilliseconds = 0;
|
||||
/*31.12.9998*/ date[2].wYear = 9998;
|
||||
date[2].wMonth = 12;
|
||||
date[2].wDayOfWeek = 4;
|
||||
date[2].wDay = 31;
|
||||
date[2].wHour = 0;
|
||||
date[2].wMinute = 0;
|
||||
date[2].wSecond = 0;
|
||||
date[2].wMilliseconds = 0;
|
||||
/*01.01.1601*/ date[3].wYear = 1601;
|
||||
date[3].wMonth = 1;
|
||||
date[3].wDayOfWeek = 1;
|
||||
date[3].wDay = 1;
|
||||
date[3].wHour = 0;
|
||||
date[3].wMinute = 0;
|
||||
date[3].wSecond = 0;
|
||||
date[3].wMilliseconds = 0;
|
||||
/*02.01.1601*/ date[4].wYear = 1601;
|
||||
date[4].wMonth = 1;
|
||||
date[4].wDayOfWeek = 2;
|
||||
date[4].wDay = 2;
|
||||
date[4].wHour = 0;
|
||||
date[4].wMinute = 0;
|
||||
date[4].wSecond = 0;
|
||||
date[4].wMilliseconds = 0;
|
||||
/*10.05.2008*/ date[5].wYear = 2008;
|
||||
date[5].wMonth = 5;
|
||||
date[5].wDayOfWeek = 6;
|
||||
date[5].wDay = 10;
|
||||
date[5].wHour = 0;
|
||||
date[5].wMinute = 0;
|
||||
date[5].wSecond = 0;
|
||||
date[5].wMilliseconds = 0;
|
||||
/*10.03.2008*/ date[6].wYear = 2008;
|
||||
date[6].wMonth = 3;
|
||||
date[6].wDayOfWeek = 1;
|
||||
date[6].wDay = 10;
|
||||
date[6].wHour = 0;
|
||||
date[6].wMinute = 0;
|
||||
date[6].wSecond = 0;
|
||||
date[6].wMilliseconds = 0;
|
||||
/*29.02.2008*/ date[7].wYear = 2008;
|
||||
date[7].wMonth = 2;
|
||||
date[7].wDayOfWeek = 5;
|
||||
date[7].wDay = 29;
|
||||
date[7].wHour = 0;
|
||||
date[7].wMinute = 0;
|
||||
date[7].wSecond = 0;
|
||||
date[7].wMilliseconds = 0;
|
||||
/*28.02.2007*/ date[8].wYear = 2007;
|
||||
date[8].wMonth = 2;
|
||||
date[8].wDayOfWeek = 3;
|
||||
date[8].wDay = 28;
|
||||
date[8].wHour = 0;
|
||||
date[8].wMinute = 0;
|
||||
date[8].wSecond = 0;
|
||||
date[8].wMilliseconds = 0;
|
||||
/*10.03.2007*/ date[9].wYear = 2007;
|
||||
date[9].wMonth = 3;
|
||||
date[9].wDayOfWeek = 6;
|
||||
date[9].wDay = 10;
|
||||
date[9].wHour = 0;
|
||||
date[9].wMinute = 0;
|
||||
date[9].wSecond = 0;
|
||||
date[9].wMilliseconds = 0;
|
||||
/*10.05.2007*/ date[10].wYear = 2007;
|
||||
date[10].wMonth = 5;
|
||||
date[10].wDayOfWeek = 4;
|
||||
date[10].wDay = 10;
|
||||
date[10].wHour = 0;
|
||||
date[10].wMinute = 0;
|
||||
date[10].wSecond = 0;
|
||||
date[10].wMilliseconds = 0;
|
||||
/*29.01.2008*/ date[11].wYear = 2008;
|
||||
date[11].wMonth = 1;
|
||||
date[11].wDayOfWeek = 2;
|
||||
date[11].wDay = 29;
|
||||
date[11].wHour = 0;
|
||||
date[11].wMinute = 0;
|
||||
date[11].wSecond = 0;
|
||||
date[11].wMilliseconds = 0;
|
||||
/*28.01.2007*/ date[12].wYear = 2007;
|
||||
date[12].wMonth = 1;
|
||||
date[12].wDayOfWeek = 0;
|
||||
date[12].wDay = 28;
|
||||
date[12].wHour = 0;
|
||||
date[12].wMinute = 0;
|
||||
date[12].wSecond = 0;
|
||||
date[12].wMilliseconds = 0;
|
||||
/*31.01.2008*/ date[13].wYear = 2008;
|
||||
date[13].wMonth = 1;
|
||||
date[13].wDayOfWeek = 4;
|
||||
date[13].wDay = 31;
|
||||
date[13].wHour = 0;
|
||||
date[13].wMinute = 0;
|
||||
date[13].wSecond = 0;
|
||||
date[13].wMilliseconds = 0;
|
||||
/*31.03.2008*/ date[14].wYear = 2008;
|
||||
date[14].wMonth = 3;
|
||||
date[14].wDayOfWeek = 1;
|
||||
date[14].wDay = 31;
|
||||
date[14].wHour = 0;
|
||||
date[14].wMinute = 0;
|
||||
date[14].wSecond = 0;
|
||||
date[14].wMilliseconds = 0;
|
||||
|
||||
// Date Differences
|
||||
dateDifference[0].year = 1;
|
||||
dateDifference[0].month = 1;
|
||||
dateDifference[1].month = 1;
|
||||
dateDifference[1].day = 10;
|
||||
dateDifference[2].day = 2;
|
||||
/*date[2]-[0]*/ dateDifference[3].week = 52;
|
||||
dateDifference[3].day = 1;
|
||||
/*date[2]-[0]*/ dateDifference[4].year = 1;
|
||||
dateDifference[5].day = 365;
|
||||
dateDifference[6].month = 1;
|
||||
dateDifference[7].month = 1;
|
||||
dateDifference[7].day = 2;
|
||||
dateDifference[8].day = 31;
|
||||
dateDifference[9].month = 11;
|
||||
dateDifference[9].day = 1;
|
||||
dateDifference[10].year = 8398;
|
||||
dateDifference[10].month = 11;
|
||||
dateDifference[10].day = 30;
|
||||
dateDifference[11].year = 2008;
|
||||
dateDifference[12].year = 7991;
|
||||
dateDifference[12].month = 11;
|
||||
dateDifference[13].week = 416998;
|
||||
dateDifference[13].day = 1;
|
||||
|
||||
/* Test Cases */
|
||||
|
||||
// Date Difference test cases
|
||||
datetimeDifftest[0].startDate = date[0];
|
||||
datetimeDifftest[0].endDate = date[3];
|
||||
datetimeDifftest[0].dateDiff = dateDifference[10];
|
||||
datetimeDifftest[1].startDate = date[0];
|
||||
datetimeDifftest[1].endDate = date[2];
|
||||
datetimeDifftest[1].dateDiff = dateDifference[5];
|
||||
datetimeDifftest[2].startDate = date[0];
|
||||
datetimeDifftest[2].endDate = date[2];
|
||||
datetimeDifftest[2].dateDiff = dateDifference[4];
|
||||
datetimeDifftest[3].startDate = date[0];
|
||||
datetimeDifftest[3].endDate = date[2];
|
||||
datetimeDifftest[3].dateDiff = dateDifference[3];
|
||||
datetimeDifftest[4].startDate = date[14];
|
||||
datetimeDifftest[4].endDate = date[7];
|
||||
datetimeDifftest[4].dateDiff = dateDifference[7];
|
||||
datetimeDifftest[5].startDate = date[14];
|
||||
datetimeDifftest[5].endDate = date[7];
|
||||
datetimeDifftest[5].dateDiff = dateDifference[8];
|
||||
datetimeDifftest[6].startDate = date[11];
|
||||
datetimeDifftest[6].endDate = date[8];
|
||||
datetimeDifftest[6].dateDiff = dateDifference[9];
|
||||
datetimeDifftest[7].startDate = date[13];
|
||||
datetimeDifftest[7].endDate = date[0];
|
||||
datetimeDifftest[7].dateDiff = dateDifference[12];
|
||||
datetimeDifftest[8].startDate = date[13];
|
||||
datetimeDifftest[8].endDate = date[0];
|
||||
datetimeDifftest[8].dateDiff = dateDifference[13];
|
||||
|
||||
// Date Add Out of Bound test cases (Negative tests)
|
||||
/*OutofBound*/ datetimeBoundAdd[0].startDate = date[1];
|
||||
datetimeBoundAdd[0].endDate = date[0];
|
||||
datetimeBoundAdd[0].dateDiff = dateDifference[2]; // on Add date[0] not used
|
||||
/*OutofBound*/ datetimeBoundAdd[1].startDate = date[2];
|
||||
datetimeBoundAdd[1].endDate = date[0];
|
||||
datetimeBoundAdd[1].dateDiff = dateDifference[11]; // on Add date[0] not used
|
||||
|
||||
// Date Subtract Out of Bound test cases (Negative tests)
|
||||
/*OutofBound*/ datetimeBoundSubtract[0].startDate = date[3];
|
||||
datetimeBoundSubtract[0].endDate = date[0];
|
||||
datetimeBoundSubtract[0].dateDiff = dateDifference[2]; // on subtract date[0] not used
|
||||
/*OutofBound*/ datetimeBoundSubtract[1].startDate = date[14];
|
||||
datetimeBoundSubtract[1].endDate = date[0];
|
||||
datetimeBoundSubtract[1].dateDiff = dateDifference[11]; // on subtract date[0] not used
|
||||
|
||||
// Date Add test cases (Positive tests)
|
||||
datetimeAddCase[0].startDate = date[13];
|
||||
datetimeAddCase[0].endDate = date[7];
|
||||
datetimeAddCase[0].dateDiff = dateDifference[6]; // add
|
||||
datetimeAddCase[1].startDate = date[14];
|
||||
datetimeAddCase[1].endDate = date[5];
|
||||
datetimeAddCase[1].dateDiff = dateDifference[1]; // add
|
||||
datetimeAddCase[2].startDate = date[13];
|
||||
datetimeAddCase[2].endDate = date[6];
|
||||
datetimeAddCase[2].dateDiff = dateDifference[1]; // add
|
||||
|
||||
// Date Subtract test cases (Positive tests)
|
||||
datetimeSubtractCase[0].startDate = date[14];
|
||||
datetimeSubtractCase[0].endDate = date[7];
|
||||
datetimeSubtractCase[0].dateDiff = dateDifference[6]; // subtract
|
||||
datetimeSubtractCase[1].startDate = date[6];
|
||||
datetimeSubtractCase[1].endDate = date[11];
|
||||
datetimeSubtractCase[1].dateDiff = dateDifference[1]; // subtract
|
||||
datetimeSubtractCase[2].startDate = date[9];
|
||||
datetimeSubtractCase[2].endDate = date[12];
|
||||
datetimeSubtractCase[2].dateDiff = dateDifference[1]; // subtract
|
||||
}
|
||||
|
||||
TEST_METHOD(DateCalcViewModelInitializationTest)
|
||||
{
|
||||
auto viewModel = ref new DateCalculatorViewModel();
|
||||
@@ -683,7 +685,6 @@ TEST_METHOD(DateCalcViewModelAddSubtractInitTest)
|
||||
TEST_METHOD(DateCalcViewModelDateDiffDaylightSavingTimeTest)
|
||||
{
|
||||
auto viewModel = ref new DateCalculatorViewModel();
|
||||
|
||||
viewModel->IsDateDiffMode = true;
|
||||
VERIFY_IS_TRUE(viewModel->IsDateDiffMode);
|
||||
|
||||
@@ -922,8 +923,6 @@ TEST_METHOD(DateCalcViewModelDateDiffFromDateHigherThanToDate)
|
||||
// contains the DayOfWeek, Day, Month, and Year
|
||||
TEST_METHOD(DateCalcViewModelAddSubtractResultAutomationNameTest)
|
||||
{
|
||||
auto viewModel = ref new DateCalculatorViewModel();
|
||||
|
||||
auto cal = ref new Calendar();
|
||||
cal->Year = 2007;
|
||||
cal->Month = 5;
|
||||
@@ -934,6 +933,8 @@ TEST_METHOD(DateCalcViewModelAddSubtractResultAutomationNameTest)
|
||||
cal->Second = 0;
|
||||
|
||||
DateTime startDate = cal->GetDateTime();
|
||||
auto viewModel = ref new DateCalculatorViewModel();
|
||||
|
||||
viewModel->StartDate = startDate;
|
||||
|
||||
viewModel->IsDateDiffMode = false;
|
||||
@@ -955,7 +956,7 @@ TEST_METHOD(DateCalcViewModelAddSubtractResultAutomationNameTest)
|
||||
|
||||
TEST_METHOD(JaEraTransitionAddition)
|
||||
{
|
||||
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||
auto engine = ref new DateCalculationEngine(CalendarIdentifiers::Japanese);
|
||||
auto cal = ref new Calendar();
|
||||
|
||||
// The Showa period ended in Jan 1989.
|
||||
@@ -973,10 +974,9 @@ TEST_METHOD(JaEraTransitionAddition)
|
||||
DateDifference yearDuration;
|
||||
yearDuration.year = 1;
|
||||
|
||||
DateTime actualYearResult;
|
||||
viewModel->AddDuration(startTime, yearDuration, &actualYearResult);
|
||||
auto actualYearResult = engine->AddDuration(startTime, yearDuration);
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult.UniversalTime);
|
||||
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult->Value.UniversalTime);
|
||||
|
||||
cal->Year = 1989;
|
||||
cal->Month = 2;
|
||||
@@ -987,15 +987,14 @@ TEST_METHOD(JaEraTransitionAddition)
|
||||
DateDifference monthDuration;
|
||||
monthDuration.month = 1;
|
||||
|
||||
DateTime actualMonthResult;
|
||||
viewModel->AddDuration(startTime, monthDuration, &actualMonthResult);
|
||||
auto actualMonthResult = engine->AddDuration(startTime, monthDuration);
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult.UniversalTime);
|
||||
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult->Value.UniversalTime);
|
||||
}
|
||||
|
||||
TEST_METHOD(JaEraTransitionSubtraction)
|
||||
{
|
||||
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||
auto engine = ref new DateCalculationEngine(CalendarIdentifiers::Japanese);
|
||||
auto cal = ref new Calendar();
|
||||
|
||||
// The Showa period ended in Jan 1989.
|
||||
@@ -1013,10 +1012,9 @@ TEST_METHOD(JaEraTransitionSubtraction)
|
||||
DateDifference yearDuration;
|
||||
yearDuration.year = 1;
|
||||
|
||||
DateTime actualYearResult;
|
||||
viewModel->SubtractDuration(startTime, yearDuration, &actualYearResult);
|
||||
auto actualYearResult = engine->SubtractDuration(startTime, yearDuration);
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult.UniversalTime);
|
||||
VERIFY_ARE_EQUAL(expectedYearResult.UniversalTime, actualYearResult->Value.UniversalTime);
|
||||
|
||||
cal->Year = 1989;
|
||||
cal->Month = 1;
|
||||
@@ -1027,15 +1025,14 @@ TEST_METHOD(JaEraTransitionSubtraction)
|
||||
DateDifference monthDuration;
|
||||
monthDuration.month = 1;
|
||||
|
||||
DateTime actualMonthResult;
|
||||
viewModel->SubtractDuration(startTime, monthDuration, &actualMonthResult);
|
||||
auto actualMonthResult = engine->SubtractDuration(startTime, monthDuration);
|
||||
|
||||
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult.UniversalTime);
|
||||
VERIFY_ARE_EQUAL(expectedMonthResult.UniversalTime, actualMonthResult->Value.UniversalTime);
|
||||
}
|
||||
|
||||
TEST_METHOD(JaEraTransitionDifference)
|
||||
{
|
||||
auto viewModel = make_unique<DateCalculationEngine>(CalendarIdentifiers::Japanese);
|
||||
auto engine = ref new DateCalculationEngine(CalendarIdentifiers::Japanese);
|
||||
auto cal = ref new Calendar();
|
||||
|
||||
// The Showa period ended in Jan 8, 1989. Pick 2 days across that boundary
|
||||
@@ -1049,10 +1046,12 @@ TEST_METHOD(JaEraTransitionDifference)
|
||||
cal->Day = 20;
|
||||
auto endTime = cal->GetDateTime();
|
||||
|
||||
DateDifference diff;
|
||||
VERIFY_IS_TRUE(viewModel->TryGetDateDifference(startTime, endTime, DateUnit::Day, &diff));
|
||||
VERIFY_ARE_EQUAL(diff.day, 19);
|
||||
auto diff = engine->TryGetDateDifference(startTime, endTime, DateUnit::Day);
|
||||
VERIFY_IS_NOT_NULL(diff);
|
||||
VERIFY_ARE_EQUAL(diff->Value.day, 19);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
DateCalculationEngine ^ DateCalculatorUnitTests::m_DateCalcEngine;
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
#pragma once
|
||||
#include "CalcViewModel/Common/CalculatorButtonUser.h"
|
||||
#include <CppUnitTest.h>
|
||||
|
||||
namespace CalculatorUnitTests
|
||||
{
|
||||
@@ -95,3 +96,15 @@ namespace CalculatorUnitTests
|
||||
{ \
|
||||
Assert::IsTrue(__expectedGreater >= __expectedLess, __VA_ARGS__); \
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void VERIFY_VECTORS_ARE_EQUAL(Windows::Foundation::Collections::IVector<T> ^ vecA, Windows::Foundation::Collections::IVector<T> ^ vecB, ...)
|
||||
{
|
||||
if (vecA->Size != vecB->Size)
|
||||
Assert::Fail();
|
||||
|
||||
for (unsigned int i = 0; i < vecA->Size; ++i)
|
||||
{
|
||||
VERIFY_ARE_EQUAL(vecA->GetAt(i), vecB->GetAt(i), __VA_ARGS__);
|
||||
}
|
||||
};
|
||||
|
@@ -75,7 +75,7 @@ namespace CalculatorFunctionalTests
|
||||
{
|
||||
m_standardViewModel->SetHistoryExpressionDisplay(e->GetTokens(), e->GetCommands());
|
||||
m_standardViewModel->SetExpressionDisplay(e->GetTokens(), e->GetCommands());
|
||||
m_standardViewModel->SetPrimaryDisplay(e->Result->Data(), false /*IsError*/);
|
||||
m_standardViewModel->SetPrimaryDisplay(e->Result, false /*IsError*/);
|
||||
m_standardViewModel->IsFToEEnabled = false;
|
||||
}
|
||||
|
||||
|
@@ -257,9 +257,26 @@ namespace CalculatorUnitTests
|
||||
void NavCategoryUnitTests::GetIndex()
|
||||
{
|
||||
// Index is the 0-based ordering of modes
|
||||
vector<ViewMode> orderedModes = { ViewMode::Standard, ViewMode::Scientific, ViewMode::Programmer, ViewMode::Date, ViewMode::Graphing,
|
||||
ViewMode::Currency, ViewMode::Area, ViewMode::Speed, ViewMode::Time, ViewMode::Power,
|
||||
ViewMode::Data, ViewMode::Pressure, ViewMode::Angle };
|
||||
ViewMode orderedModes[] = {
|
||||
ViewMode::Standard,
|
||||
ViewMode::Scientific,
|
||||
ViewMode::Programmer,
|
||||
ViewMode::Date,
|
||||
ViewMode::Graphing,
|
||||
ViewMode::Currency,
|
||||
ViewMode::Volume,
|
||||
ViewMode::Length,
|
||||
ViewMode::Weight,
|
||||
ViewMode::Temperature,
|
||||
ViewMode::Energy,
|
||||
ViewMode::Area,
|
||||
ViewMode::Speed,
|
||||
ViewMode::Time,
|
||||
ViewMode::Power,
|
||||
ViewMode::Data,
|
||||
ViewMode::Pressure,
|
||||
ViewMode::Angle
|
||||
};
|
||||
|
||||
auto orderedModesSize = size(orderedModes);
|
||||
for (size_t index = 0; index < orderedModesSize; index++)
|
||||
@@ -359,7 +376,7 @@ namespace CalculatorUnitTests
|
||||
NavCategoryGroup ^ calculatorGroup = menuOptions->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(CategoryGroupType::Calculator, calculatorGroup->GroupType);
|
||||
|
||||
IObservableVector<NavCategory ^> ^ calculatorCategories = calculatorGroup->Categories;
|
||||
IObservableVector<NavCategory^>^ calculatorCategories = calculatorGroup->Categories;
|
||||
VERIFY_ARE_EQUAL(5, calculatorCategories->Size);
|
||||
ValidateNavCategory(calculatorCategories, 0u, ViewMode::Standard, 1);
|
||||
ValidateNavCategory(calculatorCategories, 1u, ViewMode::Scientific, 2);
|
||||
|
@@ -24,7 +24,9 @@ namespace CalculatorUnitTests
|
||||
void CompareVector(IVector<T> ^ vecA, IVector<T> ^ vecB)
|
||||
{
|
||||
if (vecA->Size != vecB->Size)
|
||||
{
|
||||
Assert::Fail();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < vecA->Size; ++i)
|
||||
{
|
||||
@@ -371,27 +373,25 @@ namespace CalculatorUnitTests
|
||||
/// Low-level test of character mapping
|
||||
TEST_METHOD(VerifyCorrectCharacterMapping)
|
||||
{
|
||||
bool canSendNegate = false;
|
||||
|
||||
// Valid numbers
|
||||
NumbersAndOperatorsEnum n = m_viewModel->MapCharacterToButtonId(L'0', canSendNegate);
|
||||
NumbersAndOperatorsEnum n = m_viewModel->MapCharacterToButtonId(L'0').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::Zero);
|
||||
|
||||
n = m_viewModel->MapCharacterToButtonId(L'1', canSendNegate);
|
||||
n = m_viewModel->MapCharacterToButtonId(L'1').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::One);
|
||||
|
||||
// Valid operators
|
||||
n = m_viewModel->MapCharacterToButtonId(L'+', canSendNegate);
|
||||
n = m_viewModel->MapCharacterToButtonId(L'+').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::Add);
|
||||
|
||||
n = m_viewModel->MapCharacterToButtonId(L'=', canSendNegate);
|
||||
n = m_viewModel->MapCharacterToButtonId(L'=').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::Equals);
|
||||
|
||||
n = m_viewModel->MapCharacterToButtonId(L'a', canSendNegate);
|
||||
n = m_viewModel->MapCharacterToButtonId(L'a').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::A);
|
||||
|
||||
// Invalid character
|
||||
n = m_viewModel->MapCharacterToButtonId(L'$', canSendNegate);
|
||||
n = m_viewModel->MapCharacterToButtonId(L'$').buttonId;
|
||||
ValidateNumbersAndOperatorsAreEqual(n, NumbersAndOperatorsEnum::None);
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ namespace CalculatorUnitTests
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"15"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"17"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"1111"));
|
||||
auto val = ref new PC::Vector<bool>(64, false);
|
||||
auto val = ref new Platform::Collections::Vector<bool>(64, false);
|
||||
val->SetAt(0, true);
|
||||
val->SetAt(1, true);
|
||||
val->SetAt(2, true);
|
||||
@@ -562,7 +562,7 @@ namespace CalculatorUnitTests
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->DecimalDisplayValue), StringReference(L"123,456,789"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->OctalDisplayValue), StringReference(L"726 746 425"));
|
||||
VERIFY_ARE_EQUAL(Utils::GetStringValue(m_viewModel->BinaryDisplayValue), StringReference(L"0111 0101 1011 1100 1101 0001 0101"));
|
||||
auto val = ref new PC::Vector<bool>(64, false);
|
||||
auto val = ref new Platform::Collections::Vector<bool>(64, false);
|
||||
val->SetAt(0, true);
|
||||
val->SetAt(2, true);
|
||||
val->SetAt(4, true);
|
||||
@@ -599,7 +599,7 @@ namespace CalculatorUnitTests
|
||||
Utils::GetStringValue(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 PC::Vector<bool>(64, true);
|
||||
auto val = ref new Platform::Collections::Vector<bool>(64, true);
|
||||
val->SetAt(0, false);
|
||||
CompareVector<bool>(m_viewModel->BinaryDigits, val);
|
||||
}
|
||||
@@ -889,13 +889,13 @@ namespace CalculatorUnitTests
|
||||
};
|
||||
ValidateViewModelByCommands(m_viewModel, items, true);
|
||||
m_viewModel->OnMemoryButtonPressed();
|
||||
m_viewModel->SwitchProgrammerModeBase(RADIX_TYPE::OCT_RADIX);
|
||||
m_viewModel->SwitchProgrammerModeBase(NumberBase::OctBase);
|
||||
MemoryItemViewModel ^ memorySlotOct = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(Platform::StringReference(L"377"), Utils::GetStringValue(memorySlotOct->Value));
|
||||
m_viewModel->SwitchProgrammerModeBase(RADIX_TYPE::DEC_RADIX);
|
||||
m_viewModel->SwitchProgrammerModeBase(NumberBase::DecBase);
|
||||
MemoryItemViewModel ^ memorySlotDec = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(Platform::StringReference(L"255"), Utils::GetStringValue(memorySlotDec->Value));
|
||||
m_viewModel->SwitchProgrammerModeBase(RADIX_TYPE::BIN_RADIX);
|
||||
m_viewModel->SwitchProgrammerModeBase(NumberBase::BinBase);
|
||||
MemoryItemViewModel ^ memorySlotBin = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(Platform::StringReference(L"1111 1111"), Utils::GetStringValue(memorySlotBin->Value));
|
||||
}
|
||||
|
@@ -48,39 +48,7 @@
|
||||
#include "winrt/Windows.Globalization.DateTimeFormatting.h"
|
||||
#include "winrt/Windows.System.UserProfile.h"
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace WF = Windows::Foundation;
|
||||
namespace WUC = Windows::UI::Core;
|
||||
namespace WX = Windows::UI::Xaml;
|
||||
namespace WXC = Windows::UI::Xaml::Controls;
|
||||
namespace WXCP = Windows::UI::Xaml::Controls::Primitives;
|
||||
namespace P = Platform;
|
||||
namespace PC = Platform::Collections;
|
||||
namespace WXI = Windows::UI::Xaml::Input;
|
||||
namespace WFC = Windows::Foundation::Collections;
|
||||
namespace WS = Windows::System;
|
||||
namespace WAR = Windows::ApplicationModel::Resources;
|
||||
namespace WXMA = Windows::UI::Xaml::Media::Animation;
|
||||
namespace WXD = Windows::UI::Xaml::Data;
|
||||
namespace WXInt = Windows::UI::Xaml::Interop;
|
||||
namespace WXM = Windows::UI::Xaml::Markup;
|
||||
namespace WXA = Windows::UI::Xaml::Automation;
|
||||
}
|
||||
|
||||
// The following namespaces exist as a convenience to resolve
|
||||
// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers
|
||||
// namespace that only exist on RS3.
|
||||
// Once the app switches to min version RS3, the namespaces can be removed.
|
||||
// TODO - MSFT 12735088
|
||||
namespace StandardPeers = Windows::UI::Xaml::Automation::Peers;
|
||||
namespace CalculatorApp::Common::Automation
|
||||
{
|
||||
}
|
||||
namespace CustomPeers = CalculatorApp::Common::Automation;
|
||||
|
||||
// CalcManager Headers
|
||||
#include "CalcManager/CalculatorVector.h"
|
||||
#include "CalcManager/ExpressionCommand.h"
|
||||
#include "CalcManager/CalculatorResource.h"
|
||||
#include "CalcManager/CalculatorManager.h"
|
||||
|
Reference in New Issue
Block a user