Files
dotnet__skills/tests/dotnet-test/migrate-static-to-wrapper/eval.yaml
Amaury Levé 7e6954f9a9 Add testability migration skills and agent for dotnet-test (#518)
* Add testability migration skills and agent for dotnet-test

Introduces three skills and one orchestrator agent to help developers
incrementally replace hard-to-test static dependencies with injectable
abstractions:

- detect-static-dependencies: scans C# code for DateTime.Now, File.*,
  Environment.*, HttpClient, Console.*, Process.* and ranks by frequency
- generate-testability-wrappers: generates wrapper interfaces or guides
  adoption of built-in abstractions (TimeProvider, IHttpClientFactory,
  System.IO.Abstractions)
- migrate-static-to-wrapper: mechanical codemod-style bulk replacement of
  static call sites with wrapper calls, scoped per project/namespace
- testability-migration agent: orchestrates the Detect-Generate-Migrate
  pipeline end-to-end

Includes eval.yaml tests and fixture projects for all three skills and
the agent.

* Fix activation, token overhead, and eval timeouts

- Expand skill descriptions with more trigger phrases for
  migrate-static-to-wrapper and generate-testability-wrappers
  to fix NOT ACTIVATED issues
- Collapse verbose replacement mapping tables and constructor
  examples to reduce token overhead (~30% fewer tokens)
- Increase generate-testability-wrappers eval timeouts from
  120s to 240s to prevent timeout-impacted scoring
- Soften detect-static-dependencies scenario 2 rubric to
  reduce run-to-run variance in plugin mode
- Increase migrate-static-to-wrapper non-activation timeout
2026-04-13 15:59:41 +02:00

76 lines
3.1 KiB
YAML

scenarios:
- name: "Migrate DateTime.UtcNow to TimeProvider in a service class"
prompt: |
I have a CouponService that uses DateTime.UtcNow in several places. TimeProvider
is already registered in my DI container. Can you replace all the DateTime.UtcNow
calls with TimeProvider and add the constructor parameter?
setup:
copy_test_files: true
assertions:
- type: "file_contains"
path: "**/CouponService.cs"
value: "TimeProvider"
- type: "file_not_contains"
path: "**/CouponService.cs"
value: "DateTime.UtcNow"
- type: "exit_success"
rubric:
- "Replaced all DateTime.UtcNow calls in CouponService.cs with TimeProvider calls"
- "Added TimeProvider as a constructor parameter to CouponService"
- "Stored TimeProvider in a readonly field following the class's existing naming convention"
- "Did not change the behavior of any method — only the time source changed"
- "Did not modify Program.cs DI registration since TimeProvider was already registered"
timeout: 180
- name: "Migrate only in scoped files, leaving others untouched"
prompt: |
I want to migrate DateTime.UtcNow to TimeProvider, but only in CouponService.cs
for now. Don't touch AuditLogger.cs yet — I'll do that in a separate pass.
TimeProvider is already in my DI container.
setup:
copy_test_files: true
assertions:
- type: "file_contains"
path: "**/CouponService.cs"
value: "TimeProvider"
- type: "file_contains"
path: "**/AuditLogger.cs"
value: "DateTime.UtcNow"
- type: "exit_success"
rubric:
- "Migrated DateTime.UtcNow to TimeProvider in CouponService.cs"
- "Left AuditLogger.cs completely untouched with DateTime.UtcNow calls still present"
- "Respected the scope boundary the user specified"
- "Reported what was migrated and what remains to be done"
timeout: 180
- name: "Decline migration when wrapper does not exist yet"
prompt: |
Replace all File.ReadAllText calls in my project with IFileSystem. Just do
the bulk replacement across all files.
expect_activation: false
setup:
files:
- path: "MyProject/MyProject.csproj"
content: |
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
</Project>
- path: "MyProject/DataLoader.cs"
content: |
namespace MyProject;
public class DataLoader
{
public string Load(string path) => File.ReadAllText(path);
}
assertions:
- type: "output_matches"
pattern: "(System\\.IO\\.Abstractions|package|install|not.*registered|not.*referenced|add.*package)"
rubric:
- "Identified that System.IO.Abstractions NuGet package is not referenced in the project"
- "Did not blindly replace File.ReadAllText with IFileSystem calls that would not compile"
- "Recommended installing the package and registering IFileSystem before migrating"
timeout: 180