Add some unit tests to validate cohosting configuration#11151
Add some unit tests to validate cohosting configuration#11151davidwengier merged 6 commits intodotnet:mainfrom
Conversation
ryzngard
left a comment
There was a problem hiding this comment.
I'm definitely not an expert here but it looks reasonable to me
| { | ||
| if (endpoint is CohostSemanticTokensRangeEndpoint) | ||
| { | ||
| // We can't currently test this, as the GetRegistrations method calls requestContext.GetRequiredService |
There was a problem hiding this comment.
Can't mock structs, and RazorCohostRequestContext is a struct, which takes a roslyn RequestContext as a constructor parameter, which is also a struct :)
There was a problem hiding this comment.
ah I missed it was a struct!
|
|
||
| foreach (var registration in registrations) | ||
| { | ||
| var options = registration.RegisterOptions as ITextDocumentRegistrationOptions; |
There was a problem hiding this comment.
💭I'm not sure what the error message looks like but there is Assert.IsType<T>
There was a problem hiding this comment.
All of the standard failure messages look terrible IMO and I hate that xunit got rid of the message parameters from most of them. In this case it would be something like "IsType failed, expected ITextDocumentRegistrationOptions", so you'd have to just debug the test to find out which one was the problem.
There was a problem hiding this comment.
Tyme to start writing extension methods for ALL of XUnit :P
There was a problem hiding this comment.
Not sure that'd work out, since xUnit's Assert is a static class and we don't have the ability to create static extension methods. IMO, we'd be better off just using FluentAssertions or some other library.
There was a problem hiding this comment.
Or do the AssertEx thing for our own implementations
These tests detect an issue I ran into doing code actions, and Dustin ran into doing hover.
Also makes it impossible to forget to specify a
DocumentSelectorin a registration.