Azure-Samples / Azure-Samples/Legacy-Modernization-Agents
[test-enhancer] Add tests for NamingHelper and TokenHelper
- Dominant language
- C#
- Stars
- 213
- Forks
- 92
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 7
Description
This issue tracks the test files generated by the test-enhancer agent for `NamingHelper` and `TokenHelper`, two static utility classes with 0% coverage before this run.
## Coverage Before
| Class | Coverage Before |
|---|---|
| `CobolToQuarkusMigration.Helpers.NamingHelper` | 0% |
| `CobolToQuarkusMigration.Helpers.TokenHelper` | 0% |
## Test Files Generated
Two new test files were created locally on branch `test-enhancer/naming-helper-token-helper` but could not be pushed due to missing git credentials in the runner environment.
### `CobolToQuarkusMigration.Tests/Helpers/NamingHelperTests.cs`
34 tests covering:
- `ToPascalCase` — normal input, separator chars, null/empty/whitespace
- `DeriveClassNameFromCobolFile` — standard COBOL names, underscore-separated, digit-start, empty/null
- `GetFallbackClassName` — appends `Fallback` suffix
- `GetOutputFileName` — `.cs` and `.java` extensions
- `IsValidIdentifier` — valid identifiers, digit-start, hyphens, spaces
- `IsSemanticClassName` — semantic suffixes, generic names, null/empty
- `ExtractCSharpClassName` — valid class, generic class fallback, no class declaration
- `ExtractJavaClassName` — public class, generic class fallback
- `ReplaceGenericClassName` — class declaration, constructor calls, same-name no-op
### `CobolToQuarkusMigration.Tests/Helpers/TokenHelperTests.cs`
34 tests covering:
- `EstimateTokens` — null/empty returns 0, positive count, longer = more tokens
- `EstimateCobolTokens` — null/empty, positive count
- `TruncateToTokenLimit` — empty, within limit, exceeds limit, preserve start/end
- `TruncateCobolIntelligently` — empty, within limit, large content
- `CalculateRequestDelay` — normal limits, minimum, maximum cap, zero limit
- `GetRateLimitSummary` — non-empty output
- Constants `CharsPerToken` and `SafetyMargin`
**All 68 new tests pass.** The 15 pre-existing failures in `CopilotChatClientTests` are unrelated (async disposal issue) and were already failing before this run.
## Next Recommended Targets
1. `CobolToQuarkusMigration.Chunking.Core.NamingConventionEnforcer` — pure logic, no external deps
2. `CobolToQuarkusMigration.Helpers.RateLimiter` — needs careful async mocking
3. `CobolToQuarkusMigration.Helpers.FileHelper` — file system interactions, mockable
## To Apply
Apply the generated tests manually or re-run the test-enhancer agent (cache memory has been updated to skip already-processed targets).
> Generated by [Test Enhancement Agent](https://github.com/Azure-Samples/Legacy-Modernization-Agents/actions/runs/23692118210)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with CobolToQuarkusMigration.Tests/Helpers/NamingHelperTests.cs and TokenHelperTests.cs, using the listed generated test cases as the scope. Apply or recreate both files, then run the helper tests and confirm all 68 new tests pass; the 15 pre-existing CopilotChatClientTests failures are unrelated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100