Skip to content

NET-12: Add .NET 6 testing framework for HomeController migration#17

Open
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/net-12-1776915283-testing-framework
Open

NET-12: Add .NET 6 testing framework for HomeController migration#17
devin-ai-integration[bot] wants to merge 1 commit intomasterfrom
devin/net-12-1776915283-testing-framework

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Summary

Establishes a .NET 6 testing framework under a new netcore/ directory, alongside the existing MVC5/.NET Framework 4.5.1 solution at the repo root. Nothing in the legacy tree is modified.

Contents of netcore/:

  • SampleWebApp.NetCore.sln tying together four new projects.
  • src/SampleWebApp/ — an ASP.NET Core 6 port of HomeController (Index / About / Contact / Internals / CodeView) and a rewritten cross-platform InternalsInfo model. The model now goes through a new IInternalsInfoProvider abstraction (registered as a singleton in Program.cs) so counters can be mocked in tests.
  • tests/SampleWebApp.UnitTests/ — xUnit + Moq + FluentAssertions. 13 tests covering every HomeController action and every InternalsInfo code path. Coverlet (msbuild + collector) reports 100% line / branch / method on HomeController.cs and InternalsInfo.cs.
  • tests/SampleWebApp.IntegrationTests/ — 10 tests using WebApplicationFactory<Program>. Hits /, /Home, /Home/Index|About|Contact|Internals|CodeView over HTTP, asserts 200 OK + text/html, plus content checks on About/Internals and a 404 case. Program.cs exposes a public partial class Program { } hook so the factory can bind.
  • tests/SampleWebApp.PerformanceTests/ — BenchmarkDotNet project with HomeControllerBenchmarks (one bench per action, Index as Baseline) and InternalsInfoBenchmarks. Run on demand; not wired into CI.
  • coverlet.runsettings excluding Program.cs and *.cshtml from coverage.
  • docs/testing.md + docs/test-results.md + netcore/README.md.

.gitignore updated to exclude coverage.*.xml, TestResults/, BenchmarkDotNet.Artifacts/.

Review & Testing Checklist for Human

This PR is yellow risk — the tests all pass locally but there are a few deliberate interpretation calls that deserve a second look.

  • Scope call: NET-1 isn't done yet. NET-12's stated dependency is "HomeController migration completion," but the legacy SampleWebApp/Controllers/HomeController.cs is still MVC5. To have something testable I wrote a minimal .NET 6 port of the controller as part of this PR. Confirm this is acceptable, or split it out into a separate NET-1 PR and keep only the test harness here.
  • Behavioral drift in the migrated InternalsInfo. The original uses Windows-only PerformanceCounter("Memory", "Available MBytes"); I replaced it with GC.GetGCMemoryInfo() (available memory derived from TotalAvailableMemoryBytes - MemoryLoadBytes). HeapMemoryUsedKbytes also switched from GC.GetTotalMemory(forceFullCollection: true) to false. These values are no longer numerically equivalent to the MVC5 output — confirm this is an acceptable tradeoff for cross-platform.
  • Views are placeholders, not real migrations. About/Contact/Internals/CodeView .cshtml files are minimal stubs so the integration tests have something to render. The real content will need to come from whoever completes NET-1.
  • Performance acceptance criterion ("equal or better performance") is only partially addressed. I established a benchmark harness and baseline, but there's no automated comparison against the legacy MVC5 numbers (they can't run on Linux). Confirm this scope of "performance tests" is what the team expected.
  • Big auto-scaffolded wwwroot/. dotnet new mvc pulled in bootstrap/jquery/jquery-validation assets. They're not hand-edited but they inflate the diff significantly.

Suggested test plan

dotnet build netcore/SampleWebApp.NetCore.sln -c Release
dotnet test  netcore/tests/SampleWebApp.UnitTests/SampleWebApp.UnitTests.csproj -c Release \
  /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura \
  '/p:Include="[SampleWebApp]*"' \
  '/p:ExcludeByFile="**/Program.cs,**/*.cshtml,**/obj/**/*.cs"'
dotnet test  netcore/tests/SampleWebApp.IntegrationTests/SampleWebApp.IntegrationTests.csproj -c Release
dotnet run  --project netcore/tests/SampleWebApp.PerformanceTests -c Release -- --list flat

Also worth spot-checking coverage.cobertura.xml: Controllers/HomeController.cs and Models/InternalsInfo.cs should both be at line-rate="1".

Notes

  • No changes to the legacy MVC5 solution at the repo root.
  • The legacy repo does not have CI configured on GitHub (no .github/workflows), so CI checks may not run on this PR.
  • Closes / addresses NET-12.

Link to Devin session: https://app.devin.ai/sessions/c28119099a4e4047a4af9236a226e3e3

Establishes a .NET 6 testing framework under netcore/ alongside the legacy
MVC5 solution:

- Migrated ASP.NET Core 6 HomeController + InternalsInfo model (cross-platform,
  provider-injected for testability)
- xUnit unit test project (Moq + FluentAssertions) achieving 100% line/branch/
  method coverage on HomeController and InternalsInfo
- Integration test project using WebApplicationFactory<Program> covering every
  HomeController endpoint over HTTP
- BenchmarkDotNet performance project with per-action benchmarks
- Coverlet coverage configuration (excluding Program.cs and Razor views)
- Testing / test-results documentation under netcore/docs/

Meets NET-12 acceptance criteria (>90% HomeController coverage, integration
tests passing, performance baseline established).

Co-Authored-By: unknown <>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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

Successfully merging this pull request may close these issues.

0 participants