Skip to content

extensions: add DistinctBy and Coalesce extension methods with comprehensive test coverage#41

Merged
marioarce merged 13 commits into
developfrom
feature/new-extensions
Jul 13, 2026
Merged

extensions: add DistinctBy and Coalesce extension methods with comprehensive test coverage#41
marioarce merged 13 commits into
developfrom
feature/new-extensions

Conversation

@marioarce

Copy link
Copy Markdown
Owner
  • Added DistinctBy method to ListExtensions for deduplicating lists based on key selector
  • Added Coalesce method to StringExtensions for null-coalescing string values
  • Fixed DeepClone method in ListExtensions to handle null items correctly
  • Added comprehensive unit tests for ListExtensions including DistinctBy and DeepClone scenarios
  • Added comprehensive unit tests for StringExtensions including Coalesce scenarios

Also:

  • Removed placeholder UnitTest1.cs files from test projects
  • Updated solution and project references to support new test structure

marioarce added 11 commits July 13, 2026 12:17
 - 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
@marioarce marioarce self-assigned this Jul 13, 2026
@marioarce marioarce added the enhancement New feature or request label Jul 13, 2026
 - 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
@marioarce
marioarce merged commit 3a635ef into develop Jul 13, 2026
6 checks passed
@github-actions
github-actions Bot deleted the feature/new-extensions branch July 13, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant