try 127.0.0.1

This commit is contained in:
Tian Liao 2024-11-25 19:27:01 +08:00
commit e371b6195c
2 changed files with 7 additions and 4 deletions

View file

@ -7,7 +7,7 @@ namespace CalculatorApp
{ {
namespace DataLoaders namespace DataLoaders
{ {
static constexpr auto sc_MetadataUriLocalizeFor = L"http://localhost:4724/calctesting/file/?id=currency+static+data&localizeFor="; static constexpr auto sc_MetadataUriLocalizeFor = L"http://127.0.0.1/calctesting/file/?id=currency+static+data&localizeFor=";
static constexpr auto sc_RatiosUriRelativeTo = L"http://localhost:4724/calctesting/file/?id=currency+converter+data&localCurrency="; static constexpr auto sc_RatiosUriRelativeTo = L"http://127.0.0.1/calctesting/file/?id=currency+converter+data&localCurrency=";
} }
} }

View file

@ -16,12 +16,13 @@ namespace CalculatorUITestFramework
Prefixes = Prefixes =
{ {
// to trust below URL on your dev machine, run below command in cmd as admin // to trust below URL on your dev machine, run below command in cmd as admin
// netsh http add urlacl url="http://localhost:4724/calctesting/file" user=everyone // netsh http add urlacl url="http://127.0.0.1:80/calctesting/file" user=everyone
"http://localhost:4724/calctesting/file/", "http://127.0.0.1/calctesting/file/",
} }
}; };
_listener.Start(); _listener.Start();
_listener.BeginGetContext(OnGetContext, _listener); _listener.BeginGetContext(OnGetContext, _listener);
Console.WriteLine("MockedCurrencyServer started.");
} }
~MockedCurrencyServer() { DisposeImpl(); } ~MockedCurrencyServer() { DisposeImpl(); }
@ -49,6 +50,7 @@ namespace CalculatorUITestFramework
{ {
return; return;
} }
Console.WriteLine($"MockedCurrencyServer: on request, url = {context.Request.Url}");
var request = context.Request; var request = context.Request;
var response = context.Response; var response = context.Response;
if (request.HttpMethod == "GET" && TryGetServerFile(request.Url, out var content)) if (request.HttpMethod == "GET" && TryGetServerFile(request.Url, out var content))
@ -61,6 +63,7 @@ namespace CalculatorUITestFramework
response.OutputStream.Write(data, 0, data.Length); response.OutputStream.Write(data, 0, data.Length);
response.OutputStream.Close(); response.OutputStream.Close();
response.Close(); response.Close();
Console.WriteLine($"MockedCurrencyServer: on request, completed.");
} }
else else
{ {