从 CI 中删除 owin url 注册
Remove owin url registration from CI
我有以下 OWIN 实现 运行 我在 CI
上的功能测试
protected const string Url = "http://localhost:8785";
private static IDisposable _app;
Establish context = () => _app = WebApp.Start(Url, a =>
{
a.Use(typeof(MockIdentityMiddleware));
new Startup().Configuration(a);
});
Cleanup after = () => _app.Dispose();
但是当它 运行s 我得到以下堆栈跟踪:
System.Net.HttpListenerException: Failed to listen on prefix
'http://localhost:8785/' because it conflicts with an existing
registration on the machine.
我想以编程方式删除该端口的注册,这样我就不必再担心了,但不确定如何使用 Owin 来完成。
您不应该在测试中对端口号进行硬编码,因为您永远无法确定端口是否空闲。
有一个非常简单的代码可以在给定的机器上找到下一个空闲的 TCP 端口
我有以下 OWIN 实现 运行 我在 CI
上的功能测试 protected const string Url = "http://localhost:8785";
private static IDisposable _app;
Establish context = () => _app = WebApp.Start(Url, a =>
{
a.Use(typeof(MockIdentityMiddleware));
new Startup().Configuration(a);
});
Cleanup after = () => _app.Dispose();
但是当它 运行s 我得到以下堆栈跟踪:
System.Net.HttpListenerException: Failed to listen on prefix 'http://localhost:8785/' because it conflicts with an existing registration on the machine.
我想以编程方式删除该端口的注册,这样我就不必再担心了,但不确定如何使用 Owin 来完成。
您不应该在测试中对端口号进行硬编码,因为您永远无法确定端口是否空闲。
有一个非常简单的代码可以在给定的机器上找到下一个空闲的 TCP 端口