mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Add unit tests
This commit is contained in:
parent
ac6abc150f
commit
ba263143f9
1 changed files with 60 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
@ -387,6 +387,65 @@ namespace DateCalculationUnitTests
|
||||||
VERIFY_IS_TRUE(StringReference(L"") != viewModel->StrDateResult);
|
VERIFY_IS_TRUE(StringReference(L"") != viewModel->StrDateResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_METHOD(DateCalcViewModelDateDiffDaylightSavingTimeTest)
|
||||||
|
{
|
||||||
|
auto viewModel = ref new DateCalculatorViewModel();
|
||||||
|
|
||||||
|
viewModel->IsDateDiffMode = true;
|
||||||
|
VERIFY_IS_TRUE(viewModel->IsDateDiffMode);
|
||||||
|
|
||||||
|
/*29.02.2008*/
|
||||||
|
viewModel->FromDate = DateUtils::SystemTimeToDateTime(datetimeDifftest[5].startDate);
|
||||||
|
/*31.03.2008*/
|
||||||
|
viewModel->ToDate = DateUtils::SystemTimeToDateTime(datetimeDifftest[5].endDate);
|
||||||
|
|
||||||
|
//// Assert for the result
|
||||||
|
VERIFY_IS_FALSE(viewModel->IsDiffInDays);
|
||||||
|
VERIFY_ARE_EQUAL(StringReference(L"31 days"), viewModel->StrDateDiffResultInDays);
|
||||||
|
VERIFY_ARE_EQUAL(StringReference(L"1 month, 2 days"), viewModel->StrDateDiffResult);
|
||||||
|
|
||||||
|
// Daylight saving time - Clock Forward
|
||||||
|
/*10.03.2019*/
|
||||||
|
SYSTEMTIME startDate;
|
||||||
|
startDate.wYear = 2019;
|
||||||
|
startDate.wMonth = 03;
|
||||||
|
startDate.wDay = 10;
|
||||||
|
startDate.wDayOfWeek = 0;
|
||||||
|
startDate.wHour = startDate.wMinute = 0;
|
||||||
|
startDate.wSecond = startDate.wMilliseconds = 0;
|
||||||
|
viewModel->FromDate = DateUtils::SystemTimeToDateTime(startDate);
|
||||||
|
/*11.03.2019*/
|
||||||
|
SYSTEMTIME endDate;
|
||||||
|
endDate.wYear = 2019;
|
||||||
|
endDate.wMonth = 03;
|
||||||
|
endDate.wDay = 11;
|
||||||
|
endDate.wDayOfWeek = 0;
|
||||||
|
endDate.wHour = endDate.wMinute = 0;
|
||||||
|
endDate.wSecond = endDate.wMilliseconds = 0;
|
||||||
|
viewModel->ToDate = DateUtils::SystemTimeToDateTime(endDate);
|
||||||
|
//// Assert for the result
|
||||||
|
VERIFY_IS_TRUE(viewModel->IsDiffInDays);
|
||||||
|
VERIFY_ARE_EQUAL(StringReference(L"1 day"), viewModel->StrDateDiffResult);
|
||||||
|
|
||||||
|
endDate.wDay += 6;
|
||||||
|
viewModel->ToDate = DateUtils::SystemTimeToDateTime(endDate);
|
||||||
|
//// Assert for the result
|
||||||
|
VERIFY_IS_FALSE(viewModel->IsDiffInDays);
|
||||||
|
VERIFY_ARE_EQUAL(StringReference(L"1 week"), viewModel->StrDateDiffResult);
|
||||||
|
|
||||||
|
// Daylight saving time - Clock Backward
|
||||||
|
/*03.11.2019*/
|
||||||
|
startDate.wMonth = 11;
|
||||||
|
startDate.wDay = 03;
|
||||||
|
viewModel->FromDate = DateUtils::SystemTimeToDateTime(startDate);
|
||||||
|
/*04.11.2019*/
|
||||||
|
endDate.wMonth = 11;
|
||||||
|
endDate.wDay = 04;
|
||||||
|
viewModel->ToDate = DateUtils::SystemTimeToDateTime(endDate);
|
||||||
|
VERIFY_IS_TRUE(viewModel->IsDiffInDays);
|
||||||
|
VERIFY_ARE_EQUAL(StringReference(L"1 day"), viewModel->StrDateDiffResult);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_METHOD(DateCalcViewModelAddTest)
|
TEST_METHOD(DateCalcViewModelAddTest)
|
||||||
{
|
{
|
||||||
// TODO - MSFT 10331900, fix this test
|
// TODO - MSFT 10331900, fix this test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue