Skip to content

Conversation

@magic5644
Copy link
Owner

Introduce a new IHashUtils interface and HashUtilsService class for hashing operations. Refactor existing hash computation to utilize the new interface, and add unit tests to ensure functionality and correctness.

@magic5644 magic5644 requested a review from Copilot February 27, 2025 10:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces a new IHashUtils interface and a HashUtilsService class to handle hashing operations, refactoring the existing hash computation to use the new interface while adding comprehensive unit tests.

  • Introduces the IHashUtils interface and its implementation in HashUtilsService.
  • Refactors the static HashUtils class to delegate hash computation to the new interface.
  • Adds unit tests to validate both the service implementation and the static wrapper behavior.

Reviewed Changes

File Description
CodeLineCounter.Tests/HashUtilsMockTests.cs Tests mocking of IHashUtils to ensure HashUtils correctly defers to the implementation.
CodeLineCounter.Tests/HashUtilsServiceTests.cs Provides unit tests for the HashUtilsService behavior under different input conditions.
CodeLineCounter/Utils/HashUtilsService.cs Implements the hashing algorithm using SHA256 and returns a hex string representation.
CodeLineCounter/AssemblyInfo.cs Adds InternalsVisibleTo attribute for test accessibility.
CodeLineCounter/Utils/IHashUtils.cs Declares the IHashUtils interface with a ComputeHash method signature.
CodeLineCounter.Tests/HashUtilsTests.cs Confirms that the static HashUtils class initializes its Implementation and defers to it.
CodeLineCounter/Utils/HashUtils.cs Refactors the static hash computation to utilize the IHashUtils implementation.

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

@magic5644 magic5644 requested a review from Copilot February 27, 2025 10:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR implements a new hashing utility by introducing an IHashUtils interface and a corresponding HashUtilsService class. It refactors the existing HashUtils static class to delegate computation to the new service and adds comprehensive unit tests to ensure functionality.

  • Introduces IHashUtils and HashUtilsService for hashing operations.
  • Refactors HashUtils static class to use dependency injection via an internal Implementation property.
  • Adds new tests (including mock-based tests) to validate both the service and integration behaviors.

Reviewed Changes

File Description
CodeLineCounter.Tests/HashUtilsMockTests.cs Added unit tests using mocks to validate the delegation via HashUtils.Implementation.
CodeLineCounter.Tests/HashUtilsServiceTests.cs New tests covering various input scenarios for the HashUtilsService.
CodeLineCounter/Utils/HashUtilsService.cs New implementation of the hashing utility using SHA256 and string.Create.
CodeLineCounter/AssemblyInfo.cs Added InternalsVisibleTo attribute for test visibility.
CodeLineCounter/Utils/IHashUtils.cs New IHashUtils interface defining the hashing contract.
CodeLineCounter.Tests/HashUtilsTests.cs Extended tests to ensure the default Implementation is initialized correctly.
CodeLineCounter/Utils/HashUtils.cs Refactored static helper to delegate to the new interface implementation.

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

@magic5644 magic5644 merged commit 8c11145 into main Feb 27, 2025
11 checks passed
@sonarqubecloud
Copy link

@magic5644 magic5644 deleted the feature-add-hashutils-interface branch February 27, 2025 11:16
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.

2 participants