Manually remove OWIN WebApp

I am trying to use OWIN for the Self-Host Web API during the execution of my tests, and I want to run it in BeforeEach and dwell on AfterEach methods.

All the examples I found suggest using the using keyword, for example.

 using (WebApp.Start<Startup>(url: baseAddress)) { ... } 

But in my case, this does not help.

I tried to do like this:

 private IDisposable _webApp; public override void BeforeEach() { _webApp = WebApp.Start<OwinStartup>("http://localhost:99999/"); } public override void AfterEach() { base.AfterEach(); if (_webApp != null) _webApp.Dispose(); } 

But for some reason, it calls the Dispose method of the UnityResolver class, and then I get a stackoverflow... exception stackoverflow...

How to host an OWIN host?

+6
source share
1 answer

As noted in the comments by @drax, my implementation of the utility is correct .

The problem was my internal implementation in the UnityResolver class, which was initiated in the OwinStartup class.

However, I came across some other restrictions related to the OAuth authorization server with Owin, so I decided not to overexert my code and not use Owin. At least for now.

0
source

Source: https://habr.com/ru/post/987516/


All Articles