From 8faa95256738e835b16c60cb43d1c9c6a05b5322 Mon Sep 17 00:00:00 2001 From: Bugra Cuhadaroglu Date: Mon, 9 Nov 2020 20:14:19 -0500 Subject: [PATCH] Adding code review feedback. --- src/CalcViewModel/UnitConverterViewModel.cpp | 4 +- ...cs => CurrencyConverterFunctionalTests.cs} | 19 ++++++++-- src/CalculatorUnitTests/UnitConverterTest.cpp | 37 +++++++++++++++++++ 3 files changed, 56 insertions(+), 4 deletions(-) rename src/CalculatorUITests/{UnitConverterFunctionalTests.cs => CurrencyConverterFunctionalTests.cs} (89%) diff --git a/src/CalcViewModel/UnitConverterViewModel.cpp b/src/CalcViewModel/UnitConverterViewModel.cpp index a0e299f9..a159cf7f 100644 --- a/src/CalcViewModel/UnitConverterViewModel.cpp +++ b/src/CalcViewModel/UnitConverterViewModel.cpp @@ -474,7 +474,9 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object ^ parameter) static constexpr UCM::Command OPERANDS[] = { UCM::Command::Zero, UCM::Command::One, UCM::Command::Two, UCM::Command::Three, UCM::Command::Four, UCM::Command::Five, UCM::Command::Six, UCM::Command::Seven, UCM::Command::Eight, UCM::Command::Nine }; - if (m_isInputBlocked && (command != UCM::Command::Clear && command != UCM::Command::Backspace)) + if (m_isInputBlocked && + command != UCM::Command::Clear && + command != UCM::Command::Backspace) { return; } diff --git a/src/CalculatorUITests/UnitConverterFunctionalTests.cs b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs similarity index 89% rename from src/CalculatorUITests/UnitConverterFunctionalTests.cs rename to src/CalculatorUITests/CurrencyConverterFunctionalTests.cs index 56248980..fc8d669e 100644 --- a/src/CalculatorUITests/UnitConverterFunctionalTests.cs +++ b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs @@ -8,7 +8,7 @@ using System; namespace CalculatorUITests { [TestClass] - public class UnitConverterFunctionalTests + public class CurrencyConverterFunctionalTests { private static UnitConverterPage page = new UnitConverterPage(); @@ -51,13 +51,26 @@ namespace CalculatorUITests } #region Basic UI Functionality via Mouse Input Tests - /// /// These automated tests verify clicking each of the buttons in the Calculator UI and getting an expected result /// Via mouse input, all basic UI functionality is checked /// [TestMethod] [Priority(0)] + public void MouseInput_EnterInputAndCheckTheResult() + { + //Verifies the 2 is entered and clear is functional + page.UnitConverterOperators.NumberPad.Num2Button.Click(); + Assert.AreEqual("2", page.UnitConverterResults.GetCalculationResult1Text()); //verifies 2 button + Assert.AreEqual("2", page.UnitConverterResults.GetCalculationResult2Text()); //verifies 2 button + } + + /// + /// These automated tests verify clicking each of the buttons in the Calculator UI and getting an expected result + /// Via mouse input, all basic UI functionality is checked + /// + [TestMethod] + [Priority(1)] public void MouseInput_EnterInputWithFullDecimalAndClear() { //Verifies the 20.42 is entered and clear is functional @@ -87,7 +100,7 @@ namespace CalculatorUITests /// Via mouse input, all basic UI functionality is checked /// [TestMethod] - [Priority(0)] + [Priority(1)] public void MouseInput_EnterInputWithFullDecimalAndClearWithBackspace() { //Verifies the 20.42 is entered and clear is functional diff --git a/src/CalculatorUnitTests/UnitConverterTest.cpp b/src/CalculatorUnitTests/UnitConverterTest.cpp index 3c4a8f28..17c6d32b 100644 --- a/src/CalculatorUnitTests/UnitConverterTest.cpp +++ b/src/CalculatorUnitTests/UnitConverterTest.cpp @@ -202,6 +202,8 @@ namespace UnitConverterUnitTests TEST_METHOD(UnitConverterTestQuote); TEST_METHOD(UnitConverterTestUnquote); TEST_METHOD(UnitConverterTestBackspace); + TEST_METHOD(UnitConverterTestBackspaceBasic); + TEST_METHOD(UnitConverterTestClear); TEST_METHOD(UnitConverterTestScientificInputs); TEST_METHOD(UnitConverterTestSupplementaryResultRounding); TEST_METHOD(UnitConverterTestMaxDigitsReached); @@ -291,6 +293,41 @@ namespace UnitConverterUnitTests VERIFY_IS_TRUE(s_testVMCallback->CheckSuggestedValues(vector>(begin(test2), end(test2)))); } + + // Verify a basic copy paste steam. '20.43' with backspace button pressed + void UnitConverterTest::UnitConverterTestBackspaceBasic() + { + s_unitConverter->SendCommand(Command::Two); + s_unitConverter->SendCommand(Command::Zero); + s_unitConverter->SendCommand(Command::Decimal); + s_unitConverter->SendCommand(Command::Four); + s_unitConverter->SendCommand(Command::Three); + s_unitConverter->SendCommand(Command::Backspace); + + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"20.4"), wstring(L"20.4"))); + s_unitConverter->SendCommand(Command::Backspace); + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"20."), wstring(L"20"))); + s_unitConverter->SendCommand(Command::Backspace); + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"20"), wstring(L"20"))); + s_unitConverter->SendCommand(Command::Backspace); + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"2"), wstring(L"2"))); + s_unitConverter->SendCommand(Command::Backspace); + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"0"), wstring(L"0"))); + } + + // Verify a basic copy paste steam. '20.43' with backspace button pressed + void UnitConverterTest::UnitConverterTestClear() + { + s_unitConverter->SendCommand(Command::Two); + s_unitConverter->SendCommand(Command::Zero); + s_unitConverter->SendCommand(Command::Decimal); + s_unitConverter->SendCommand(Command::Four); + s_unitConverter->SendCommand(Command::Three); + s_unitConverter->SendCommand(Command::Clear); + + VERIFY_IS_TRUE(s_testVMCallback->CheckDisplayValues(wstring(L"0"), wstring(L"0"))); + } + // Check the getter functions void UnitConverterTest::UnitConverterTestGetters() {