Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tian-lt committed Nov 25, 2024
1 parent a4b09e0 commit 6370f28
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/CalculatorUITests/CurrencyConverterFunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
using System;
using System.Diagnostics;
using System.Threading;
using CalculatorUITestFramework;

using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand All @@ -25,6 +26,7 @@ public static void ClassInitialize(TestContext context)
{
// Create session to launch a Calculator window
_currencyServer = new MockedCurrencyServer();
Thread.Sleep(5000);
CalculatorDriver.Instance.SetupCalculatorSession(context);
}

Expand All @@ -45,8 +47,10 @@ public static void ClassCleanup()
[TestInitialize]
public void TestInit()
{
VerifyConnection();
VerifyConnection("http://localhost/calctesting/file/?id=currency+converter+data&localCurrency=en-US");
VerifyConnection("http://localhost/calctesting/file/?id=currency+static+data&localizeFor=en-US");
CalculatorApp.EnsureCalculatorHasFocus();
Thread.Sleep(5000);
page.EnsureCalculatorIsCurrencyMode();
page.EnsureCalculatorResultTextIsZero();
page.EnsureSameUnitsAreSelected();
Expand All @@ -58,14 +62,15 @@ public void TestCleanup()
page.ClearAll();
}

private static void VerifyConnection()
private static void VerifyConnection(string url)
{
Console.WriteLine($"VerifyConnection begins: url: {url}");
var process = new Process();
var startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = @"/C curl ""http://localhost/calctesting/file/?id=currency+converter+data&localCurrency=""",
Arguments = @$"/C curl ""{url}""",
RedirectStandardOutput = true, // Redirect the standard output
UseShellExecute = false,
CreateNoWindow = true
Expand All @@ -74,7 +79,7 @@ private static void VerifyConnection()
process.Start();
var debug = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Console.WriteLine($"----------- exitcode: {process.ExitCode}, curl result: {debug}");
Console.WriteLine($"VerifyConnection ends: exitcode: {process.ExitCode}, curl result: {debug}");
}

private string NormalizeCurrencyText(string realValue, int fractionDigits)
Expand Down

0 comments on commit 6370f28

Please sign in to comment.