Skip to content

Unit tests for DasBlogSettings - #728

Merged
poppastring merged 6 commits into
mainfrom
creating-more-unit-tests
Aug 21, 2025
Merged

poppastring merged 6 commits into
mainfrom
creating-more-unit-tests

Conversation

@poppastring

Copy link
Copy Markdown
Owner

PR Classification

Improved test coverage and refactored test structure for better maintainability and robustness.

PR Summary

This pull request adds comprehensive unit tests for StringExtension methods and the DasBlogSettings class, refactors test organization, and enhances test coverage for edge cases.

  • StringExtensionTest.cs: Added extensive unit tests for string manipulation methods and moved the class to a new namespace (DasBlog.Tests.UnitTests.Extensions).
  • DasBlogSettingsTests.cs: Introduced a new test class with mocking for dependencies and added tests for URL generation, time zone adjustments, and admin validation.
  • Removed the old, less comprehensive implementation of StringExtensionTest from DasBlog.Tests.UnitTests.Misc.
  • Enhanced test coverage for edge cases, including configurations like UseAspxExtension and TitlePermalinkSpaceReplacement.
  • Improved code readability and organization with logical grouping of related tests.

- Added tests for `RemoveLineBreaks`, `StripHtml`, and `StripHTMLFromText`.
- Added tests for `RemoveDoubleSpaceCharacters` and `CutLongString`.
- Added tests for `RemoveQuotationMarks` and `FindFirstImage`.
- Added tests for `FindFirstYouTubeVideo` with and without `<iframe>`.
- Improved test coverage and reliability for string extensions.
* Updated namespace from `Misc` to `ExtensionsConfig` for clarity.
* Removed and re-added `StringExtensionTest` class with no logic changes.
* Retained all test methods for string extension functionality.
* Aligned file structure with new project organization.
* Refactored `StringExtensionTest.cs` with namespace update and formatting changes; functionality of string extension tests remains unchanged.
* Added `DasBlogSettingsTests` in `DasBlogSettingsTests.cs` to test `DasBlogSettings` behavior, including `GetBaseUrl` method with mocked dependencies.
- Added new namespaces to support additional functionality.
- Introduced `SiteConfig` and `List<User>` fields for testing.
- Refactored test setup into a reusable `CreateSettings` method.
- Replaced and expanded test cases to cover more functionality.
- Enhanced test coverage for configuration options like `.aspx`.
- Added edge case tests for comments, users, and HTML filtering.
- Improved test assertions for more specific validation.
- Simulated realistic data for user and configuration testing.
- Incorporated time-based tests using `DateTime.UtcNow` and `NodaTime`.
- Improved maintainability with helper methods and better structure.
- Updated `FindFirstImage` to return a tuple `(url, alt)` instead of just `src`.
- Refactored `FindHeroImage` to use the new `FindFirstImage` and handle its tuple return type.
- Enhanced unit tests for `FindHeroImage` and `FindFirstImage` to validate both `src` and `alt` attributes.
- Added new tests for `FindFirstImage` to handle cases with and without images.
- Removed outdated `FindFirstImage` implementation and its associated tests.
- Improved code readability with clearer comments and better regex usage.
- Fixed fallback logic in `FindHeroImage` for the new tuple return type.
- Applied minor formatting improvements for consistency and clarity.
@poppastring
poppastring merged commit 14517cf into main Aug 21, 2025
@poppastring
poppastring deleted the creating-more-unit-tests branch August 21, 2025 15:05
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.

1 participant