Add ASP.NET Core testing series samples on .NET 10 - #2118
Open
vladimir-pecanac-main wants to merge 1 commit into
Open
Add ASP.NET Core testing series samples on .NET 10#2118vladimir-pecanac-main wants to merge 1 commit into
vladimir-pecanac-main wants to merge 1 commit into
Conversation
Bring the whole "Testing ASP.NET Core Applications" series into this repository, one folder per article under dotnet-testing/AspNetCoreTestingSeries, so the samples build and their tests run in CI like every other sample here. - StartingProject, UnitTestingWithXUnit, TestingMvcControllers, IntegrationTestingMvc, TestingAntiForgeryToken and UiTestingSelenium, each with its own solution, plus a convenience solution that builds all six together. - Retarget every project to net10.0 and move EF Core, ASP.NET Core testing, xUnit, Moq, Selenium and the test SDK to current releases (the apps were still on EF Core 6.0.0-rc previews). - Remove the duplicate InitialMigration left over from EF Core 2.2. It clashed with the 2021 migration the model snapshot actually matches, and it stopped four of the six projects from compiling at all. - Handle a null account number in AccountNumberValidation instead of passing a nullable string into a non-nullable parameter from the controller. - Swap the database provider in TestingWebAppFactory the way EF Core 10 needs it, removing the options configuration as well as the options themselves, so the integration tests run against the in-memory provider again. - The Selenium UI tests need a browser and a running application, so they are built but left out of automated test discovery, and Selenium Manager now supplies ChromeDriver instead of a pinned package. All six solutions build on .NET 10 and all 90 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the whole Testing ASP.NET Core Applications series into this repository, one folder per article under
dotnet-testing/AspNetCoreTestingSeries, so the samples build and their tests run in CI like every other sample here. The code came from the separatetesting-aspnetcore-mvcrepository, where it lived on six branches and had not been touched since 2021.Layout —
StartingProject(the app the series starts from),UnitTestingWithXUnit,TestingMvcControllers,IntegrationTestingMvc,TestingAntiForgeryToken,UiTestingSelenium. Each folder has its own solution so a reader can open just the article they are on;AspNetCoreTestingSeries.slnbuilds and tests all six together.What had to change to get it running on .NET 10
net10.0, with EF Core, ASP.NET Core testing, xUnit, Moq, Selenium and the test SDK moved to current releases. The apps were still referencing EF Core6.0.0-rcpreviews.Migrations/held twoInitialMigrationclasses in one namespace, one from EF Core 2.2 and one from 6.0. The model snapshot matches the 2021 one, so the 2.2 leftover is removed.AccountNumberValidation.IsValidnow takes a nullable string and rejects a null or empty account number, instead of the controller passingEmployee.AccountNumber(string?) into a non-nullable parameter.TestingWebAppFactoryremovesIDbContextOptionsConfiguration<EmployeeContext>as well asDbContextOptions<EmployeeContext>. Removing only the options is no longer enough — EF Core keeps the provider registration separately, so the SQL Server and in-memory providers both ended up registered and every integration test failed.https://localhost:5001, so they cannot run unattended. They are built as part of the solution but excluded from automated test discovery, and Selenium Manager now resolves ChromeDriver instead of a package pinned to Chrome 95.Verification — all six solutions build on .NET 10.0.10 and all 90 tests pass (78 unit, 12 integration; the 3 Selenium UI tests are build-only, as described above).
The
wwwroot/libfolders are the vendored Bootstrap/jQuery assets that ship with each copy of the app, matching how the other MVC samples in this repository are stored.