Skip to content

Commit b159a89

Browse files
committed
enable internet server for development
1 parent 6370f28 commit b159a89

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

src/Calculator/Package.appxmanifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@
6363
</Applications>
6464
<Capabilities>
6565
<Capability Name="internetClient" />
66+
<Capability Name="internetClientServer"/>
6667
</Capabilities>
6768
</Package>

src/CalculatorUITestFramework/MockedCurrencyServer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ private void DisposeImpl()
4040
private static void OnGetContext(IAsyncResult result)
4141
{
4242
var listener = (HttpListener)result.AsyncState;
43-
var context = listener.EndGetContext(result);
43+
HttpListenerContext context;
44+
try
45+
{
46+
context = listener.EndGetContext(result);
47+
}
48+
catch (HttpListenerException)
49+
{
50+
return;
51+
}
4452
var request = context.Request;
4553
var response = context.Response;
4654
if (request.HttpMethod == "GET" && TryGetServerFile(request.Url, out var content))

src/CalculatorUITests/CurrencyConverterFunctionalTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public static void ClassInitialize(TestContext context)
2626
{
2727
// Create session to launch a Calculator window
2828
_currencyServer = new MockedCurrencyServer();
29-
Thread.Sleep(5000);
3029
CalculatorDriver.Instance.SetupCalculatorSession(context);
3130
}
3231

@@ -47,10 +46,7 @@ public static void ClassCleanup()
4746
[TestInitialize]
4847
public void TestInit()
4948
{
50-
VerifyConnection("http://localhost/calctesting/file/?id=currency+converter+data&localCurrency=en-US");
51-
VerifyConnection("http://localhost/calctesting/file/?id=currency+static+data&localizeFor=en-US");
5249
CalculatorApp.EnsureCalculatorHasFocus();
53-
Thread.Sleep(5000);
5450
page.EnsureCalculatorIsCurrencyMode();
5551
page.EnsureCalculatorResultTextIsZero();
5652
page.EnsureSameUnitsAreSelected();
@@ -62,26 +58,6 @@ public void TestCleanup()
6258
page.ClearAll();
6359
}
6460

65-
private static void VerifyConnection(string url)
66-
{
67-
Console.WriteLine($"VerifyConnection begins: url: {url}");
68-
var process = new Process();
69-
var startInfo = new ProcessStartInfo
70-
{
71-
WindowStyle = ProcessWindowStyle.Hidden,
72-
FileName = "cmd.exe",
73-
Arguments = @$"/C curl ""{url}""",
74-
RedirectStandardOutput = true, // Redirect the standard output
75-
UseShellExecute = false,
76-
CreateNoWindow = true
77-
};
78-
process.StartInfo = startInfo;
79-
process.Start();
80-
var debug = process.StandardOutput.ReadToEnd();
81-
process.WaitForExit();
82-
Console.WriteLine($"VerifyConnection ends: exitcode: {process.ExitCode}, curl result: {debug}");
83-
}
84-
8561
private string NormalizeCurrencyText(string realValue, int fractionDigits)
8662
{
8763
if (!realValue.Contains('.')) return realValue;

0 commit comments

Comments
 (0)