diff --git a/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs b/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs index 22154f4f..e514ec16 100644 --- a/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs +++ b/src/CalculatorUITestFramework/ScientificOperatorsPanel.cs @@ -17,8 +17,9 @@ namespace CalculatorUITestFramework public enum FEButtonState { - Normal, - Exponential + Auto, + Scientific, + Engineering } /// @@ -78,11 +79,14 @@ namespace CalculatorUITestFramework public WindowsElement RandButton => this.session.TryFindElementByAccessibilityId("randButton"); public WindowsElement DmsButton => this.session.TryFindElementByAccessibilityId("dmsButton"); public WindowsElement DegreesButton => this.session.TryFindElementByAccessibilityId("degreesButton"); - public WindowsElement FixedToExponentialButton => this.session.TryFindElementByAccessibilityId("ftoeButton"); + public WindowsElement AutoButton => this.session.TryFindElementByAccessibilityId("autoButton"); + public WindowsElement SciButton => this.session.TryFindElementByAccessibilityId("sciButton"); + public WindowsElement EngButton => this.session.TryFindElementByAccessibilityId("engButton"); public WindowsElement NegateButton => this.session.TryFindElementByAccessibilityId("negateButton"); public WindowsElement ShiftButton => this.session.TryFindElementByAccessibilityId("shiftButton"); public WindowsElement TrigFlyout => this.session.TryFindElementByAccessibilityId("Trigflyout"); public WindowsElement LightDismiss => this.session.TryFindElementByAccessibilityId("Light Dismiss"); + private WindowsElement AutoSciEngButton => GetNumberFormatButton(); private WindowsElement DegRadGradButton => GetAngleOperatorButton(); private WindowsElement GetAngleOperatorButton() { @@ -103,6 +107,25 @@ namespace CalculatorUITestFramework throw new NotFoundException("Could not find deg, rad or grad button in page source"); } + private WindowsElement GetNumberFormatButton() + { + string source = this.session.PageSource; + if (source.Contains("autoButton")) + { + return AutoButton; + } + else if (source.Contains("sciButton")) + { + return SciButton; + } + else if (source.Contains("engButton")) + { + return EngButton; + } + + throw new NotFoundException("Could not find auto, sci, or eng button in page source"); + } + /// /// Set the state of the degrees, radians and gradians buttons. /// @@ -122,11 +145,19 @@ namespace CalculatorUITestFramework } } - public void ResetFEButton(FEButtonState value) + public void SetNumberFormat(FEButtonState value) { - if (this.FixedToExponentialButton.GetAttribute("Toggle.ToggleState") != "0") + //set the desired string value for the button + string desiredId = value switch { - FixedToExponentialButton.Click(); + FEButtonState.Auto => "autoButton", + FEButtonState.Scientific => "sciButton", + FEButtonState.Engineering => "engButton", + _ => throw new NotImplementedException() + }; + while (this.AutoSciEngButton.GetAttribute("AutomationId") != desiredId) + { + this.AutoSciEngButton.Click(); } } diff --git a/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs index e1d8cc41..5c2724fc 100644 --- a/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs +++ b/src/CalculatorUITests/CurrencyConverterFunctionalTests.cs @@ -3,6 +3,7 @@ using CalculatorUITestFramework; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; namespace CalculatorUITests { diff --git a/src/CalculatorUITests/ScientificModeFunctionalTests.cs b/src/CalculatorUITests/ScientificModeFunctionalTests.cs index 21e43f0b..b377c938 100644 --- a/src/CalculatorUITests/ScientificModeFunctionalTests.cs +++ b/src/CalculatorUITests/ScientificModeFunctionalTests.cs @@ -51,7 +51,7 @@ namespace CalculatorUITests } CalculatorApp.EnsureCalculatorHasFocus(); page.ScientificOperators.SetAngleOperator(AngleOperatorState.Degrees); - page.ScientificOperators.ResetFEButton(FEButtonState.Normal); + page.ScientificOperators.SetNumberFormat(FEButtonState.Auto); } [TestCleanup] @@ -161,11 +161,22 @@ namespace CalculatorUITests [TestMethod] [Priority(0)] - public void SmokeTest_FixedToExponential() + public void SmokeTest_ScientificFormat() { - page.ScientificOperators.FixedToExponentialButton.Click(); + page.ScientificOperators.SetNumberFormat(FEButtonState.Scientific); + page.StandardOperators.NumberPad.Input(0.123); page.StandardOperators.EqualButton.Click(); - Assert.AreEqual("0.e+0", page.CalculatorResults.GetCalculatorResultText()); + Assert.AreEqual("1.23e-1", page.CalculatorResults.GetCalculatorResultText()); + } + + [TestMethod] + [Priority(0)] + public void SmokeTest_EngineeringFormat() + { + page.ScientificOperators.SetNumberFormat(FEButtonState.Engineering); + page.StandardOperators.NumberPad.Input(0.123); + page.StandardOperators.EqualButton.Click(); + Assert.AreEqual("123.e-3", page.CalculatorResults.GetCalculatorResultText()); } #endregion