extensions: add DistinctBy and Coalesce extension methods with comprehensive test coverage#41
Merged
Merged
Conversation
- Deleted UnitTest1.cs from PowerCSharp.Core.Tests containing StringExtensionsTests - Deleted UnitTest1.cs from PowerCSharp.Utilities.Tests containing placeholder test - Cleaned up test projects by removing obsolete test files
- Added DistinctBy method that removes duplicates based on a key selector function - Maintained null safety and improved code readability - Added comprehensive XML documentation for the new DistinctBy method
- Created ListExtensionsTests.cs with full test coverage for ListExtensions methods - Added 8 tests for DistinctBy method covering null, empty, duplicates, complex types, and order preservation - Added 5 tests for DeepClone method covering null, empty, cloneable items, null items, and modification independence - Included test helper classes TestPerson and TestCloneable to support test scenarios - Ensures robust validation of ListExtensions functionality
- Created StringExtensionsTests.cs with full test coverage for string extension methods - Added 4 tests for IsNullOrWhiteSpace covering null, empty, whitespace, and valid strings - Added 5 tests for SafeSubstring covering valid parameters, invalid indices, null strings, and boundary conditions - Added 5 tests for ToTitleCase covering normal conversion, empty strings, null strings, single words, and multiple spaces - Ensures robust validation of string extension functionality
- Changed expected exception from ArgumentNullException to NullReferenceException - Corrected test to properly validate null reference behavior when calling TryAdd on null dictionary - Aligns test expectations with actual runtime behavior of null reference operations
- Updated all test method calls from MathHelper to MathUtility - Changed Clamp, IsInRange, Percentage, ToRadians, ToDegrees, IsEven, and IsOdd method references - Maintains all existing test logic while using the corrected class name - Aligns tests with the actual class name in the codebase
- Changed ValidationHelper references to ValidationUtility in test methods - Updated IsNumeric method calls to use the correct class name - Maintains all existing test logic while using the proper class name - Aligns tests with the actual ValidationUtility class in the codebase
- Added PowerCSharp.Extensions project reference to PowerCSharp.Core.Tests.csproj - Reformatted ItemGroup tags in BuiltInFeatures.Tests.csproj for consistency - Reformatted ItemGroup tags in Features.Tests.csproj for consistency - Reformatted ItemGroup tags in Utilities.Tests.csproj for consistency - Ensures Core.Tests can access extension methods from PowerCSharp.Extensions
- Added PowerCSharp.Core.Tests project to solution with Debug and Release configurations - Added PowerCSharp.Compatibility.Extensions.Tests project to solution with Debug and Release configurations - Added PowerCSharp.Utilities.Tests project to solution with Debug and Release configurations - Configured nested project structure to place all three test projects under Tests folder - Ensures test projects are included in solution build and navigation
- Added Coalesce extension method that returns fallback value when raw value is null or empty - Method takes nullable string rawValue and nullable string fallback parameters - Returns rawValue when it has content, otherwise returns fallback - Includes comprehensive XML documentation for the new method - Provides convenient null-coalescing behavior for string values
- Created StringExtensionsTests.cs with full test coverage for the new Coalesce method - Added 7 tests covering null, empty, whitespace, and various null/empty combinations - Tests verify that Coalesce returns rawValue when it has content and fallback when rawValue is null or empty - Includes edge case tests for null fallback, both null, and both empty scenarios - Ensures robust validation of the Coalesce string extension method
- Added matrix strategy with ubuntu-latest and windows-latest operating systems - Changed runs-on to use matrix.os instead of hardcoded ubuntu-latest - Enables cross-platform testing for both Linux and Windows environments - Ensures code compatibility across different operating systems
…ions.Tests from solution - Reverted build-and-test job to use single ubuntu-latest runner instead of matrix strategy - Removed PowerCSharp.Compatibility.Extensions.Tests project from solution file - Cleaned up build configurations for the removed test project - Simplified CI configuration to use single platform for testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also: