Skip to content

Commit

Permalink
Merge pull request #21 from yizshi/free_up_listener
Browse files Browse the repository at this point in the history
Free Listnener after timeout test
  • Loading branch information
AaronAtDuo authored Dec 7, 2022
2 parents a9cc6c7 + 9eb14e3 commit 63b916e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/ApiCallTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ public TestDispatchHandler handler
}
}

public HttpListener listener;

public void Run()
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add("http://localhost:8080/");
listener.Start();
this.listener = new HttpListener();
this.listener.Prefixes.Add("http://localhost:8080/");
this.listener.Start();

for (int i = 0; i < requestsToHandle; i++)
{
Expand Down Expand Up @@ -118,7 +120,7 @@ public void Run()
}

// shut down the listener
listener.Stop();
this.listener.Stop();
}

private string ikey;
Expand Down Expand Up @@ -365,6 +367,9 @@ public void TestJsonTimeout()

var we = Assert.IsType<WebException>(ex);
Assert.Equal(WebExceptionStatus.Timeout, we.Status);

// Free up listener for later tests
srv.listener.Stop();
}

[Fact]
Expand Down

0 comments on commit 63b916e

Please sign in to comment.