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

fix(vscode): Resolve Hyphen Handling, Mock Generator Formatting, and Add Missing Reference Errors in Templates #6075

Merged

Conversation

samikay101
Copy link
Contributor

@samikay101 samikay101 commented Nov 12, 2024

Requirement Checklist

Work Items

Add coverlet.collector to package reference in generated csproj
Implement consistent handling of hyphens in unitTestName and WorkflowName inputs
Compile error - rootPath missing this reference
Formatting issue in mock generator helper doc comments
Uncomment var actionMocks in PREPARE Mock section

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes or features)

Type of Change

  • Bug fix
  • Feature

Issues Addressed:

New Behavior

Feature: Enhanced Naming Convention Consistency

  1. User Input Handling:

    • Users can input names with hyphens (-) in fields like unitTestName and WorkflowName.
    • Hyphens are preserved in file and folder names to respect user input preferences.
  2. Code-Level Replacement:

    • In generated .cs files, hyphens in unitTestName and WorkflowName inputs are replaced with underscores (_) to comply with C# naming conventions for methods and class names.
    • Example transformation:
      public async Task <%= WorkflowName %>-<%= UnitTestName %>_ExecuteWorkflow_SUCCESS()
      becomes:
      public async Task <%= WorkflowName %>_<%= UnitTestName %>_ExecuteWorkflow_SUCCESS()
    • Internal references to unitTestName and WorkflowName now follow consistent naming conventions, enhancing readability and reducing potential errors.
  3. File and Folder Naming:

    • File names and folder structures retain hyphens, ensuring the user’s preferred naming conventions are respected.
    • Example: A file test-order-new-successful.cs and a folder la-sample-workflow retain their hyphenated format.

Bug Fixes

  1. Compile Error (rootPath):

    • Added this reference to rootPath where required, resolving the missing reference compile error.
  2. Formatting Issues in Mock Generator Helper:

    • Resolved doc comment issues in the mock generator helper:
      • Newline added after the region block.
      • Removed extra space from the summary block.
      • Changed <actionName> to actionName, avoiding compilation errors due to angle brackets.
  3. Uncommented var actionMocks in PREPARE Mock Section:

    • Uncommented var actionMocks in the PREPARE Mock section, restoring intended functionality for the unit tests.

Impact of Change

  • This is a breaking change.

Impact Analysis

These changes standardize naming conventions and improve code maintainability, reducing potential compile-time errors due to naming inconsistencies. The updates will positively impact downstream consumers by maintaining input-based naming preferences while ensuring that C# conventions are upheld within the code. No breaking changes are expected from this update.

@ccastrotrejo ccastrotrejo merged commit 8996a76 into Azure:developer/unitTest Nov 12, 2024
1 check passed
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.

3 participants