Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Core DbContext defunct in unit tests #5

Closed
toniarnold opened this issue May 29, 2022 · 1 comment
Closed

.NET Core DbContext defunct in unit tests #5

toniarnold opened this issue May 29, 2022 · 1 comment

Comments

@toniarnold
Copy link
Owner

toniarnold commented May 29, 2022

Since a forced upgrade to .NET 5 (for Blazor .NET 6), DbContext Core requires DI Logging, thus unit tests requiring DbContext fail in the VS Test Explorer.

As soon as asplib.blazor gets referenced in test.core, we get a MissingMethodException at LoggerFactory.Create(). If the reference is only removed, the DbTest tests using DBContext pass. Problem is the reference to Microsoft.AspNetCore.Components.Web.

toniarnold added a commit that referenced this issue May 29, 2022
DbContext Core requires DI Logging, but only referencing
Microsoft.AspNetCore.Components.Web breaks the LoggerFactory
on runtime with MissingMethodException.

SetUpDbContext() in tests now set up a test-specific ServiceProvider
with the NullLoggerFactory which gets applied by
optionsBuilder.UseInternalServiceProvider(ServiceProvider).

Update EF Core to 5.0.17
@toniarnold
Copy link
Owner Author

Fixed with commit 166f19b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant