JasperFx / alba

Easy integration testing for ASP.NET Core applications
https://jasperfx.github.io/alba
Apache License 2.0
407 stars 39 forks source link

Unit tests for Alba.AspNetCore2 #46

Closed rytmis closed 6 years ago

rytmis commented 6 years ago

So, I'm fairly sure this doesn't pass muster as it is, but I figured I'd get your opinion on how to proceed from here.

After about four hours of furious debugging, I was able to figure out that the tests didn't pass because for whatever reason, when running under the test harness, the Application Part discovery for the WebApp wasn't finding controllers at all.

This is only an issue within Alba's own test suite, because I have a packaged version that I've been using to TDD an API project for a couple of months now, and it works as expected. In any case, grabbing the type of the startup class and registering its assembly as an Application Part fixed all but two of the tests, so I'm not feeling too bad about this. The relevant changes are all in SystemUnderTest.cs.

The remaining two test failures have to do with testing Windows authentication. The entire authentication stack has changed for ASP.NET Core 2.0, so I cobbled together something that makes the tests pass. There are two problems here, though:

First, the API has to be different, as configuring this authentication mechanism has to happen as part of the Configure step, not within the Scenario call. I haven't resolved this in any meaningful way yet, because it's an API compatibility issue I don't feel qualified to resolve.

Second, I have no idea if the authentication handler I wrote actually does the right thing for the tests to be meaningful.