public void ComputeWithMoreThanOneParenthesis_Should_Be_Sum_First_Then_Product_And_Difference() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("5"); calculatorApp.Input("*"); calculatorApp.Input("("); calculatorApp.Input("3"); calculatorApp.Input("+"); calculatorApp.Input("2"); calculatorApp.Input(")"); calculatorApp.Input("*"); calculatorApp.Input("("); calculatorApp.Input("1"); calculatorApp.Input("+"); calculatorApp.Input("2"); calculatorApp.Input(")"); calculatorApp.Input("-"); calculatorApp.Input("1"); calculatorApp.Input("0"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 65; Assert.AreEqual(expectedResult, actualResult); }
public void TestInit() { CalculatorApp.EnsureCalculatorHasFocus(); page.EnsureCalculatorIsCurrencyMode(); page.EnsureCalculatorResultTextIsZero(); page.EnsureSameUnitsAreSelected(); }
public MortageFragment() { this.app = CalculatorApp.Default; this.calc = new MortgageCalculator(); this.calc.Interest = 4.5f / 12f; this.calc.Periods = 30 * 12; }
public void ComputeMoreThanOneDigitWithDecimalNumbersWithParenthesis_Should_Be_Product_And_Sum() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("2"); calculatorApp.Input("1"); calculatorApp.Input("."); calculatorApp.Input("5"); calculatorApp.Input("3"); calculatorApp.Input("*"); calculatorApp.Input("("); calculatorApp.Input("3"); calculatorApp.Input("9"); calculatorApp.Input("."); calculatorApp.Input("6"); calculatorApp.Input("7"); calculatorApp.Input("+"); calculatorApp.Input("4"); calculatorApp.Input("0"); calculatorApp.Input("."); calculatorApp.Input("4"); calculatorApp.Input("7"); calculatorApp.Input(")"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 1725.4; Assert.AreEqual(expectedResult, actualResult); }
public void MixedInput_Operators_ClearEntryClear() { //Verify Clear Entery page.StandardOperators.NumberPad.Input(3); CalculatorApp.Window.SendKeys(Keys.Add); CalculatorApp.Window.SendKeys("3"); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys(Keys.Delete); Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText()); Assert.AreEqual("3 +", page.CalculatorResults.GetCalculatorExpressionText()); page.StandardOperators.NumberPad.Input(9); CalculatorApp.Window.SendKeys(Keys.Subtract); CalculatorApp.Window.SendKeys("6"); page.StandardOperators.ClearEntryButton.Click(); Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText()); Assert.AreEqual("3 + 9 Minus (", page.CalculatorResults.GetCalculatorExpressionText()); //Verify Clear page.StandardOperators.NumberPad.Input(6); CalculatorApp.Window.SendKeys(Keys.Subtract); CalculatorApp.Window.SendKeys("9"); page.StandardOperators.ClearButton.Click(); page.CalculatorResults.IsResultsExpressionClear(); }
public void KeyboardInput_HistoryHotkeys() { //Verifies history buttons CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("4"); CalculatorApp.Window.SendKeys(Keys.Multiply); CalculatorApp.Window.SendKeys("5"); CalculatorApp.Window.SendKeys(Keys.Divide); CalculatorApp.Window.SendKeys("2"); CalculatorApp.Window.SendKeys(Keys.Equal); page.HistoryPanel.ResizeWindowToDisplayHistoryButton(); CalculatorApp.Window.SendKeys(Keys.Control + "h" + Keys.Control); var historyFlyoutItems = page.HistoryPanel.GetAllHistoryFlyoutListViewItems(); var historyExpression = Regex.Replace(historyFlyoutItems[0].GetExpression(), @"\s", string.Empty); Assert.IsTrue(historyFlyoutItems[0].GetValue().Equals("10", StringComparison.InvariantCultureIgnoreCase)); //verifies History button hotkeys Assert.IsTrue(historyExpression.Equals("4×5÷2=", StringComparison.InvariantCultureIgnoreCase)); //verifies History button hotkeys page.HistoryPanel.ResizeWindowToDisplayHistoryLabel(); var historyItems = page.HistoryPanel.GetAllHistoryListViewItems(); Assert.IsTrue(historyItems[0].GetValue().Equals("10", StringComparison.InvariantCultureIgnoreCase)); Assert.IsTrue(historyExpression.Equals("4×5÷2=", StringComparison.InvariantCultureIgnoreCase)); CalculatorApp.Window.SendKeys(Keys.Shift + Keys.Control + "d" + Keys.Control + Keys.Shift); Assert.IsNotNull(WinAppDriver.Instance.CalculatorSession.FindElementByAccessibilityId("HistoryEmpty")); //verifies the History panel's clear history button hotkeys }
public void ComputeMoreThanOneDigitWithDecimalNumbersWithParenthesis_Should_Be_QuotientFirst_And_Difference() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("("); calculatorApp.Input("9"); calculatorApp.Input("1"); calculatorApp.Input("."); calculatorApp.Input("5"); calculatorApp.Input("3"); calculatorApp.Input("/"); calculatorApp.Input("5"); calculatorApp.Input("9"); calculatorApp.Input("."); calculatorApp.Input("6"); calculatorApp.Input("7"); calculatorApp.Input(")"); calculatorApp.Input("-"); calculatorApp.Input("0"); calculatorApp.Input("."); calculatorApp.Input("5"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 1.0; Assert.AreEqual(expectedResult, actualResult); }
public void KeyboardInput_PercentSquareRootBackspaceDecimalNegateOneZero() { //Verifies the %, square root, backspace, decimal, negate, 1, and 0 button CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("100"); CalculatorApp.Window.SendKeys(Keys.Backspace); Assert.AreEqual("10", page.CalculatorResults.GetCalculatorResultText()); // verifies using the 1 key, the 0 key, and the backspace key CalculatorApp.Window.SendKeys(Keys.Add); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift); Assert.AreEqual("1", page.CalculatorResults.GetCalculatorResultText()); //verifies percent calculation Assert.AreEqual("10 + 1", page.CalculatorResults.GetCalculatorExpressionText()); //verifies percent hotkey CalculatorApp.Window.SendKeys(Keys.Shift); CalculatorApp.Window.SendKeys(Keys.Shift + "5" + Keys.Shift); CalculatorApp.Window.SendKeys(Keys.Shift); CalculatorApp.Window.SendKeys(Keys.Shift + "2" + Keys.Shift); Assert.AreEqual("0.3162277660168379", page.CalculatorResults.GetCalculatorResultText()); //verifies square root calculation Assert.AreEqual("10 + √(0.1)", page.CalculatorResults.GetCalculatorExpressionText()); //verifies 2√x hotkey CalculatorApp.Window.SendKeys("."); Assert.AreEqual("0 point", page.CalculatorResults.GetCalculatorResultText()); //verifies using decimal key CalculatorApp.Window.SendKeys(Keys.F9); CalculatorApp.Window.SendKeys("1"); Assert.AreEqual("-0.1", page.CalculatorResults.GetCalculatorResultText()); //verifies negate hotkey page.StandardOperators.EqualButton.Click(); Assert.AreEqual("9.9", page.CalculatorResults.GetCalculatorResultText()); //verifies calculation with decimal point and negative number }
public void ComputeWithMoreThanOneDigitAndDecimalNumbers_Should_Be_Sum_And_Product_And_Quotient() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("2"); calculatorApp.Input("4"); calculatorApp.Input("."); calculatorApp.Input("5"); calculatorApp.Input("9"); calculatorApp.Input("+"); calculatorApp.Input("3"); calculatorApp.Input("8"); calculatorApp.Input("."); calculatorApp.Input("5"); calculatorApp.Input("4"); calculatorApp.Input("*"); calculatorApp.Input("1"); calculatorApp.Input("0"); calculatorApp.Input("."); calculatorApp.Input("1"); calculatorApp.Input("/"); calculatorApp.Input("2"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 318.8; Assert.AreEqual(expectedResult, actualResult); }
public MortageFragment() { this.app = CalculatorApp.Default; this.calc = new MortgageCalculator (); this.calc.Interest = 4.5f / 12f; this.calc.Periods = 30 * 12; }
public void AoT_ButtonOnlyInStandard() { page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.ScientificCalculator); Assert.AreEqual("Scientific", CalculatorApp.GetCalculatorHeaderText()); page.StandardAoTCalculatorPage.GetAoTPresence(); Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence()); CalculatorApp.EnsureCalculatorHasFocus(); page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.ProgrammerCalculator); Assert.AreEqual("Programmer", CalculatorApp.GetCalculatorHeaderText()); page.StandardAoTCalculatorPage.GetAoTPresence(); Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence()); CalculatorApp.EnsureCalculatorHasFocus(); page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.DateCalculator); Assert.AreEqual("Date Calculation", CalculatorApp.GetCalculatorHeaderText()); page.StandardAoTCalculatorPage.GetAoTPresence(); Assert.AreEqual("False", page.StandardAoTCalculatorPage.GetAoTPresence()); CalculatorApp.EnsureCalculatorHasFocus(); page.NavigationMenu.ChangeCalculatorMode(CalculatorMode.StandardCalculator); Assert.AreEqual("Standard", CalculatorApp.GetCalculatorHeaderText()); page.StandardAoTCalculatorPage.GetAoTPresence(); Assert.AreEqual("True", page.StandardAoTCalculatorPage.GetAoTPresence()); }
public void MixedInput_Operators_SquareRoot() { //Verify Square root page.StandardOperators.NumberPad.Input(9); page.StandardOperators.XPower2Button.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("81", page.CalculatorResults.GetCalculatorResultText()); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void Run() { IApplication app = new CalculatorApp(); IAppRouteConfig routeConfig = new AppRouteConfig(); app.Start(routeConfig); this.webServer = new WebServer(Port, routeConfig); this.webServer.Run(); }
public void TestInit() { if ("0" != page.CalculatorResults.GetCalculatorResultText()) { page.ClearAll(); } CalculatorApp.EnsureCalculatorHasFocus(); page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees); page.ScientificOperators.ResetFEButton(FEButtonState.Normal); }
public void MixedInput_Operators_Decimal() { //Verify Decimal page.StandardOperators.NumberPad.Input(3); page.StandardOperators.NumberPad.DecimalButton.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("2"); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("3.2", page.CalculatorResults.GetCalculatorResultText()); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void TestInit() { if ("0" != page.CalculatorResults.GetCalculatorResultText()) { page.ClearAll(); } CalculatorApp.EnsureCalculatorHasFocus(); page.ProgrammerOperators.SetArithmeticShift(); page.ProgrammerOperators.ResetWordSize(); page.ProgrammerOperators.ResetNumberSystem(); }
public static void ClassInitialize(TestContext context) { // Create session to launch a Calculator window WinAppDriver.Instance.SetupCalculatorSession(context); // Ensure that calculator is in standard mode page.NavigateToStandardCalculator(); // Ensure that calculator window is large enough to display the memory/history panel; a good size for most tests CalculatorApp.ResizeWindowToDisplayMemoryHistoryDockPanel(); }
public void MixedInput_Operators_Division() { //Verify Division page.StandardOperators.NumberPad.Input(6); page.StandardOperators.MultiplyButton.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("2"); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("12", page.CalculatorResults.GetCalculatorResultText()); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void MixedInput_Operators_PositiveNegative() { //Verify Positive/Negative (plus/minus) page.StandardOperators.NumberPad.Input(3); page.StandardOperators.MinusButton.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("2"); page.StandardOperators.NegateButton.Click(); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText()); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void MixedInput_Operators_PercentAdditionSubtraction() { //Verify Percent addition/subtraction page.StandardOperators.NumberPad.Input(10); page.StandardOperators.MinusButton.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("10"); page.StandardOperators.PercentButton.Click(); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("9", page.CalculatorResults.GetCalculatorResultText()); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void DoubleDecimalSymbol_Should_Be_ThrowError() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("1"); calculatorApp.Input("."); calculatorApp.Input("."); calculatorApp.Input("5"); calculatorApp.Input("+"); calculatorApp.Input("2"); var actualResult = calculatorApp.GetAnswer(); }
static void Main(string[] args) { var userInteraction = new UserInteraction(); var calculatorApp = new CalculatorApp(new DefaultExchangeService(), userInteraction); userInteraction.DisplayMessage(CalculatorApp.HELP_MESSAGE); userInteraction.DisplayMessage("Other Commands: HELP, EXIT"); Command lastExecutedCommand = null; while (!(lastExecutedCommand is ExitCommand)) { lastExecutedCommand = calculatorApp.ProcessCommand(); } }
public void MixedInput_Operators_Equal() { //Verify Equal page.HistoryPanel.ClearHistory(); page.StandardOperators.EqualButton.Click(); CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("0", page.CalculatorResults.GetCalculatorResultText()); var historyItems = page.HistoryPanel.GetAllHistoryListViewItems(); Assert.IsTrue(historyItems[0].Text.Equals("0= 0", StringComparison.InvariantCultureIgnoreCase)); Assert.IsTrue(historyItems[1].Text.Equals("0= 0", StringComparison.InvariantCultureIgnoreCase)); CalculatorApp.Window.SendKeys(Keys.Escape); }
public void AddTwoNumbers_Should_Be_Sum() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("2"); calculatorApp.Input("+"); calculatorApp.Input("3"); var actualResult = calculatorApp.GetAnswer(); //assert var expectedResult = 5; Assert.AreEqual(expectedResult, actualResult); }
public void SubtractTwoNumbers_Should_Be_Difference() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("5"); calculatorApp.Input("-"); calculatorApp.Input("3"); var actualResult = calculatorApp.GetAnswer(); //assert var expectedResult = 2; Assert.AreEqual(expectedResult, actualResult); }
public void MultiplyTwoNumbers_Should_Be_Product() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("5"); calculatorApp.Input("*"); calculatorApp.Input("3"); var actualResult = calculatorApp.GetAnswer(); //assert var expectedResult = 15; Assert.AreEqual(expectedResult, actualResult); }
public void DivideTwoNumbers_Should_Be_Quotient() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("6"); calculatorApp.Input("/"); calculatorApp.Input("3"); var actualResult = calculatorApp.GetAnswer(); //assert var expectedResult = 2; Assert.AreEqual(expectedResult, actualResult); }
public void ComputeOperatorSequenceAddSubtract_Should_Be_Difference() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("5"); calculatorApp.Input("+"); calculatorApp.Input("-"); calculatorApp.Input("3"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 2; Assert.AreEqual(expectedResult, actualResult); }
public void CalculatorApp_MultipleOperations_ReturnsCorrectResult() { // 5 * 2 + 6 = 16 var calculatorForm = new CalculatorApp(); calculatorForm.btnFive.PerformClick(); calculatorForm.btnMultiply.PerformClick(); calculatorForm.btnTwo.PerformClick(); calculatorForm.btnAdd.PerformClick(); Assert.AreEqual( "10", calculatorForm.displayBox.Text ); calculatorForm.btnSix.PerformClick(); calculatorForm.btnCalculate.PerformClick(); Assert.AreEqual( "16", calculatorForm.displayBox.Text ); }
public void ComputeThreeNumbers_Should_Be_Sum_And_Product() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("2"); calculatorApp.Input("+"); calculatorApp.Input("3"); calculatorApp.Input("*"); calculatorApp.Input("4"); var actualResult = calculatorApp.GetAnswer(); //assert var expectedResult = 20; Assert.AreEqual(expectedResult, actualResult); }
public void ComputeOperatorSequenceAddSubtractDivide_Should_Be_Quotient() { //arrange CalculatorApp calculatorApp = new CalculatorApp(); //act calculatorApp.Input("1"); calculatorApp.Input("0"); calculatorApp.Input("+"); calculatorApp.Input("-"); calculatorApp.Input("/"); calculatorApp.Input("2"); var actualResult = calculatorApp.GetAnswer(); //assert double expectedResult = 5; Assert.AreEqual(expectedResult, actualResult); }
public void KeyboardInput_MultiplyDivideEqualFourFiveSix() { //Verifies the multiplication, division, and equal, 4, 5, and 6 key input CalculatorApp.EnsureCalculatorHasFocus(); CalculatorApp.Window.SendKeys("4"); Assert.AreEqual("4", page.CalculatorResults.GetCalculatorResultText()); //verifies using 4 key CalculatorApp.Window.SendKeys(Keys.Multiply); Assert.AreEqual("4 ×", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using multiplication key CalculatorApp.Window.SendKeys("5"); Assert.AreEqual("5", page.CalculatorResults.GetCalculatorResultText()); //verifies using 5 key CalculatorApp.Window.SendKeys(Keys.Divide); Assert.AreEqual("20", page.CalculatorResults.GetCalculatorResultText()); //verifies multiplication Assert.AreEqual("4 × 5 ÷", page.CalculatorResults.GetCalculatorExpressionText()); //verifies using divide key CalculatorApp.Window.SendKeys("6"); Assert.AreEqual("6", page.CalculatorResults.GetCalculatorResultText()); //verifies using 6 key CalculatorApp.Window.SendKeys(Keys.Equal); Assert.AreEqual("3.333333333333333", page.CalculatorResults.GetCalculatorResultText()); //verifies division Assert.AreEqual("4 × 5 ÷ 6=", page.CalculatorResults.GetCalculatorExpressionText()); //verifies equal key }
public CalculatorFragment() { this.app = CalculatorApp.Default; }
public ITPadApp GetAppInstance(TPadApplicationDescriptor descriptor, ITPadAppContainer container, ITPadAppController controller, TPadCore core, TPadLauncherSettings settings) { CalculatorApp calculator = new CalculatorApp(core, container, controller, descriptor.AppUUID); calculator.Activate(settings.Context); return calculator; }