Repository navigation
Creating additional unit tests - #729
Merged
Merged
Conversation
- Removed `DasBlogSettingTest` class from `DasBlogSettingTest.cs`. - Added `DasBlogSettingsMock` as a mock implementation of `IDasBlogSettings`. - Updated unit tests to use `DasBlogSettingsMock` instead of `DasBlogSettingTest`. - Refactored test data in `TagHelperTest.cs` to use `DasBlogSettingsMock`.
* Centralized mock setup logic in `DasBlogSettingsMock` to reduce duplication. * Updated all test methods to use `DasBlogSettingsMock.CreateSettings()`. * Simplified `DasBlogSettingsTests` constructor by replacing individual mock setups. * Added a static `DasBlogSettings` instance in `TagHelperTest` for reuse. * Updated `DasBlogPostLinkTagHelperData` to use centralized settings. * Removed unused methods and properties from `DasBlogSettingsMock`. * Improved test readability, maintainability, and consistency across the suite. * Fixed minor test assertion issues to align with updated mock configurations.
* Removed `CommentContentTagHelperTest.cs`, `PostToFacebookTagHelperTest.cs`, and `PostToLinkedInTagHelperTest.cs`. * Moved all test cases from the removed files into `TagHelperTest.cs`.
- Added tests for `SitePageControlTagHelper` to verify pagination rendering. - Added tests for `PostCategoriesListTagHelper` to validate category rendering. - Added tests for `SiteDescriptionTagHelper` to ensure description rendering. - Added tests for `SiteRootTagHelper` to verify root URL rendering. - Added tests for `SiteTitleTagHelper` to validate title rendering. - Used mocked `DasBlogSettings` to simulate configuration settings. - Improved test coverage to reduce regression risks.
- Expanded `XmlRpcManagerTest` with comprehensive test coverage. - Added mock setups for `IDasBlogSettings`, `ISiteSecurityManager`, etc. - Implemented helper method to create `XmlRpcManager` instances. - Added tests for methods like `mt_publishPost`, `mt_getCategoryList`. - Verified behavior for Blogger API enable/disable scenarios. - Configured mocks to simulate dependencies and test edge cases. - Ensured robust assertions for method outputs and exceptions.
- Introduced `SubscriptionManagerTest` to test `SubscriptionManager`. - Mocked dependencies: `IDasBlogSettings`, `ISiteConfig`, `IMetaTags`, `IBlogDataService`. - Configured mocks to simulate `SubscriptionManager` behavior. - Added helper method `CreateManager` for test setup. - Implemented xUnit tests for `GetRss`, `GetRssCategory`, `GetRsd`. - Verified `GetAtom` and `GetAtomCategory` throw `NotImplementedException`. - Added necessary `using` directives for required namespaces.
- Removed unused `Mock<IBlogDataService>` from `SubscriptionManagerTest`. - Replaced `Assert.Equal` with `Assert.Single` in `GetRssCategory_ReturnsRssRoot`. - Added `SiteSecurityManagerTest` with unit tests for password hashing, MD5 validation, user retrieval, and password verification.
- Added `SiteManagerTest` class to test `SiteManager` behavior. - Introduced mocks for `IDasBlogSettings` and `ISiteConfig`. - Implemented tests for constructor and `GetGoogleSiteMap`. - Verified `GetGoogleSiteMap` returns valid URL set with expected properties.
- Added `CategoryManagerTest` class to test `CategoryManager`. - Introduced mocks for `IDasBlogSettings` and `ISiteConfig`. - Implemented tests for `GetEntries` and `GetCategoryTitle`. - Verified `CategoryManager` instantiation with valid dependencies. - Ensured tests validate entry retrieval and category title logic.
- Added `using` directives for required namespaces to support testing. - Introduced `BlogManagerTest` class for unit testing `BlogManager`. - Mocked `IDasBlogSettings`, `ISiteConfig`, and `ILogger<BlogManager>`. - Implemented constructor to configure mock dependencies. - Added `CreateManager` helper method to instantiate `BlogManager`. - Added unit tests: - `Constructor_WithValidDependencies_ConstructsInstance`. - `GetBlogPost_ByTitle_ReturnsEntry`. - `GetEntryForEdit_ReturnsEntry`. - `GetFrontPagePosts_ReturnsEntries`. - `GetAllEntries_ReturnsEntries`.
* Updated `Constructor_WithValidDependencies_ConstructsInstance` in `CategoryManagerTest.cs` to use `Assert.True(result.Count > 22)`. * Removed `Assert.NotEmpty` and specific title check from `CategoryManagerTest.cs`. * Added `ArchiveManagerTest` class in `ArchiveManagerTest.cs` with mock setups for `IDasBlogSettings`, `ISiteConfig`, and `IBlogDataService`. * Added `CreateManager` helper method to instantiate `ArchiveManager` with mocked dependencies. * Added tests in `ArchiveManagerTest`: - `Constructor_WithValidDependencies_ConstructsInstance`: Verifies instance creation. - `GetEntriesForMonth_ReturnsEntries`: Validates 6 entries and title. - `GetEntriesForYear_ReturnsEntries`: Validates >9 entries and title. - `GetDaysWithEntries_ReturnsDates`: Validates 10 dates and specific date inclusion. - `GetEntriesForDay_ReturnsEntries`: Validates 5 entries and title.
* Updated `GetEntriesForYear_ReturnsEntries` to use `Assert.Equal(10, result.Count)` for stricter validation of entry count. * Removed `Assert.Equal(10, result.Count)` from `GetDaysWithEntries_ReturnsDates` to focus on verifying the presence of a specific date in the result.
- Removed `Mock<IBlogDataService>` from `ArchiveManagerTest`. - Added `using System.Linq;` to `XmlRpcManagerTest`. - Refactored `mt_getRecentPostTitles_ReturnsRecentPosts` test. - Added `ActivityPubManagerTest` with mocked dependencies. - Implemented unit tests for `ActivityPubManager` methods.
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.
PR Classification
Code cleanup and test suite enhancement.
PR Summary
This pull request refactors the test suite for the
DasBlogproject to improve maintainability, consistency, and test coverage. It introduces a reusable mock utility and consolidates redundant tests.DasBlogSettingTesttoDasBlogSettingsMockfor modular and reusable test setup.ActivityPubManagerTest,ArchiveManagerTest, etc.) to validate core functionality.TagHelperTestand added cases forPostToFacebookTagHelper,SitePageControlTagHelper, and others.DasBlogSettingsTeststo useDasBlogSettingsMockand improved test coverage for methods likeGetBaseUrlandCompressTitle.CommentContentTagHelperTest,PostToFacebookTagHelperTest) and unused code.