Fix disabled date calculator unit tests
Fix TestDateDiff, TestAddOob, TestAddition, and TestSubtraction unit tests in DateCalculatorUnitTests.cpp by updating API calls to match current interfaces and adding proper verification steps. These tests were previously disabled with TODO comments referencing MSFT 10331900.
@microsoft-github-policy-service agree
Hi @hanzhang54, do you know what MSFT 10331900 is? Could you help verify if our pipelines can pass once those test code is enabled? Thanks.
@tian-lt Can you please review this and suggest any changes
@
@Ronitsabhaya75 There seems to be some build errors about the changes in this PR. Could you please take a look?
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): Error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalcViewModel\Common\DateCalculator.h(55,39): see declaration of 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): while trying to match the argument list '(Windows::Foundation::DateTime, Windows::Foundation::DateTime, CalculatorApp::ViewModel::Common::DateCalculation::DateUnit, CalculatorApp::ViewModel::Common::DateCalculation::DateDifference *)'
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): Error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): No user-defined-conversion operator available, or D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): There is no context in which this conversion is possible
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,73): No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27): see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,73): No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27): see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'
@Ronitsabhaya75 There seems to be some build errors about the changes in this PR. Could you please take a look?
##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): Error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): error C2660: 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference': function does not take 4 arguments [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalcViewModel\Common\DateCalculator.h(55,39): see declaration of 'CalculatorApp::ViewModel::Common::DateCalculation::DateCalculationEngine::TryGetDateDifference' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,50): while trying to match the argument list '(Windows::Foundation::DateTime, Windows::Foundation::DateTime, CalculatorApp::ViewModel::Common::DateCalculation::DateUnit, CalculatorApp::ViewModel::Common::DateCalculation::DateDifference *)' ##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): Error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): error C2440: 'initializing': cannot convert from 'Platform::IBoxCalculatorApp::ViewModel::Common::DateCalculation::DateDifference ^' to 'bool' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): No user-defined-conversion operator available, or D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(312,30): There is no context in which this conversion is possible ##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,73): No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27): see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(376,52): while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)' ##[error]src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): Error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' 4>D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): error C2664: 'SYSTEMTIME DateCalculationUnitTests::DateUtils::DateTimeToSystemTime(Windows::Foundation::DateTime)': cannot convert argument 1 from 'Platform::IBoxWindows::Foundation::DateTime' to 'Windows::Foundation::DateTime' [D:\a_work\1\s\src\CalculatorUnitTests\CalculatorUnitTests.vcxproj] (compiling source file '/DateCalculatorUnitTests.cpp') D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,73): No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called D:\a_work\1\s\src\CalculatorUnitTests\DateUtils.h(28,27): see declaration of 'DateCalculationUnitTests::DateUtils::DateTimeToSystemTime' D:\a_work\1\s\src\CalculatorUnitTests\DateCalculatorUnitTests.cpp(403,52): while trying to match the argument list '(Platform::IBoxWindows::Foundation::DateTime)'
yes I can have look
And, something might be wrong about the checks for this PR. please allow me to close and reopen this PR so that we can trigger the GitHub Action for the PR. Thanks.
@tian-lt can you please review this changes. sorry for pushing this late i was actually busy with my intern program.
@Ronitsabhaya75 thank you for pushing a fix. Looks like we have a run time failure in UT for now. Could you help take a look?
Failed TestDateDiff [< 1 ms] Error Message: Assert failed
@Ronitsabhaya75 thank you for pushing a fix. Looks like we have a run time failure in UT for now. Could you help take a look?
Failed TestDateDiff [< 1 ms] Error Message: Assert failed
let me see that and fix it
@tian-lt i think this should fix now can you run it through all tests
@tian-lt is it possible to run the test and see if this is failing or not.
@tian-lt is it possible to run the test and see if this is failing or not.
sure. I’ve triggered a run for it. BTW, the Unit tests are able to run on your local machine. It will give you more information about the test failure.
@tian-lt is it possible to run the test and see if this is failing or not.
sure. I’ve triggered a run for it. BTW, the Unit tests are able to run on your local machine. It will give you more information about the test failure.
I tested them they were working correctly i honestly dont know why is this causing issue here
@tian-lt can you give me access to trigger those test manually for this pr for checking