-
Notifications
You must be signed in to change notification settings - Fork 0
Implement hashing functionality with IHashUtils interface and service class #31
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
Conversation
There was a problem hiding this 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.
…pdate type assertion in HashUtilsTests
There was a problem hiding this 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|



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.