Tests refactoring#80
Merged
Merged
Conversation
Merge pull request #74 from Gml-Launcher/develop
Introduced a new `displayName` property to game profiles and updated related methods, models, and interfaces to support it. This enhances the flexibility of profile naming, differentiating internal identifiers from user-facing names.
Renamed `gml-core.sln` to `Gml.Core.sln` for consistency with existing naming standards. This improves clarity and aligns with project structure conventions.
Introduce `IGitHubService` for repository operations, including branch and tag retrieval, project downloads, and file editing. Extend `ILauncherProcedures` with methods for downloading versions and retrieving available version lists. These changes improve modularity and support for GitHub-based workflows.
Introduce GitHubService to handle Git interactions, including repository branches and tags retrieval. Extend LauncherProcedures to support downloading, editing, and managing launcher files using the GitHubService. This improves modularity and simplifies interactions with Git repositories in the launcher workflow.
Simplified test setup by merging initialization logic and removing unused variables. Standardized naming conventions for constants and optimized profile creation methods. Enhanced assertions for better validation and replaced redundant checks with more concise implementations.
Replaced asynchronous logic with `Task.CompletedTask` in multiple test methods to streamline execution and disable unused code. Commented-out sections of code have been preserved for potential future use.
Restored the Gml.Core solution file with the full project structure. This includes all the project references, configurations, and nested organization for easier development management.
Updated the solution file to include new virtual folders (Loader, Core, and Common) with necessary project nesting adjustments. This change improves project organization and structure within the solution.
Introduced CurseForge as a new ModType, expanding mod source options. Updated FindModsAsync to include a ModType parameter, allowing more precise filtering during mod searches.
Refactored FindModsAsync to handle mods from Modrinth, CurseForge, or throw an error for unsupported sources. Updated related methods to return IReadOnlyCollection for consistency and added source-specific switch logic. This enhances flexibility and improves type safety in mod lookups.
Introduced tests to validate `FindModsAsync` functionality for both Modrinth and CurseForge sources. These tests ensure mods are retrieved correctly and that results match the expected types.
Replaced type-checking logic with `OfType<T>()` for better readability and consistency. Added an additional assertion for `CurseForgeMod` to ensure all expected mod types are properly validated.
Updated projects to support multiple target frameworks, including .NET 8.0 and 9.0. Enhanced mod management with added support for Modrinth and improved CurseForge integration. Streamlined logging, adjusted process execution and timeout handling, and augmented test coverage for mods and launcher operations.
Updated `IModVersion` to include file lists and enhanced `GetVersions` to support both Modrinth and CurseForge modifications using a `ModType` switch. Added validations for empty results and implemented unit tests to verify mod addition from both platforms.
# Conflicts: # tests/GmlCore.Tests/UnitTests.cs
Updated `AddProfile` calls to consistently use `name` for both the primary and secondary name parameters. This ensures that profile creation aligns with the intended naming convention and improves code clarity and maintainability.
Curse forge
* Add news provider framework with multiple integrations Introduced a new framework for fetching news, with support for VK, UnicoreCMS, Azuriom, Telegram, and custom news providers. Integrated these into existing services, added corresponding models, interfaces, and unit tests, and implemented caching and refresh mechanisms. * Add news integration endpoints and handlers Introduced functionality for adding news listeners and retrieving news using new endpoints. Implemented `NewsHandler` with support for different news provider types and created the corresponding DTO and interface files. Also updated project references and endpoint extensions to integrate the new features. * Refactor news handling to support typed INewsData and storage. Replaced INews with a new INewsData interface to improve type safety and consistency across the news ecosystem. Added storage integration for managing news listeners dynamically. Refactored providers to support the updated data model and streamlined listener handling logic. * Update NewsListenerProvider.cs and StorageConstants.cs * Add persistence and restoration for NewsProviders Implemented functionality to persist NewsProviders in storage when adding/removing listeners and retrieve them during system restoration. Introduced a `Retore` method in `INewsListenerProvider` and updated `GmlManager` to call it during the restore process. Added a new storage constant `NewsProviders` for this purpose. * Refactor NewsProvider architecture to enhance extensibility Replaced `INewsProvider` implementations with `BaseNewsProvider` and improved serialization support using a new `NewsProviderConverter`. Updated `NewsListenerProvider` to handle exceptions and support restoring providers from storage. Added new types to `NewsListenerType` and enhanced `IStorageService` methods for JSON customization. * Add RemoveListenerByType method to NewsListenerProvider Introduced a method `RemoveListenerByType` in `INewsListenerProvider` and its implementation in `NewsListenerProvider`. This allows removing all listeners of a specific type and updates the storage accordingly. * Add news type property and improve listener refresh logic Introduced `Type` property to `NewsData` and `INewsData` for better news categorization. Refactored `RefreshAsync` to return a `Task` and updated the listener logic to handle exceptions during refresh. Adjusted subscriptions and storage updates for improved reliability. * Fix typo in method name from 'Retore' to 'Restore' Renamed all instances of the incorrectly spelled 'Retore' to 'Restore' across multiple files for consistency and clarity. This change ensures accurate method naming and prevents potential confusion or errors in method usage. * Refactor caching logic and improve news listener handling. Renamed `_cache` to `_newsCache` for clearer context and updated logic to remove specific cached items when a provider is removed. Adjusted the timer initialization to ensure immediate execution and improved overall readability and maintainability of the `NewsListenerProvider` class. * Fix profile state logic and refine mod procedures handling Updated profile state assignment to ensure consistent state changes and added a `CanLoadMods` method for better mod-loading validation. Standardized parameter naming in mod-related procedures from `modrinth` to `modType` for clarity and consistency across the codebase. * Add `DisplayName` and `CanEdit` properties to game profiles Introduced `DisplayName` to improve UI labeling and `CanEdit` to indicate the modifiability of profiles. Also fixed a conditional bug in `CanLoadMods` to correctly handle unsupported loaders. These changes enhance profile management and validation. * Add CurseForge API token support and dynamic updates Introduce `AccessTokens` in `ILauncherInfo` to manage API keys, enabling dynamic updates for the CurseForge key. Refactor `ModsProcedures` to use the new token system, removing the hardcoded key and improving initialization via `LauncherInfo`. Implement null checks to ensure CurseForge API client safety during key absence. * Add 'Name' property to news providers and 'vkKey' to launcher Introduced a 'Name' property to `INewsProvider` and its implementations, allowing for consistent identification of news providers. Adjusted `LauncherInfo` to include a 'vkKey' in its settings, enabling better integration with VK-related features. Updated relevant logic to store and utilize these changes. * Refactor AzuriomNewsProvider and add RefreshAsync call. Replaced private field _url with a public property Url for consistency and updated references. Added a call to RefreshAsync in NewsListenerProvider to ensure data is refreshed after configuration changes. * Refactor VkNewsProvider to use IGmlManager and improve error handling Updated VkNewsProvider to utilize IGmlManager for token handling and dependency injection. Enhanced error handling by capturing exceptions with the bug tracker. Added support for nullable responses in VkNewsResponse and implemented naming properties in news providers. * Refactor news provider constructors to set default listener type Unified the constructors across Unicore, Azuriom, and Custom providers by removing the `NewsListenerType` parameter and setting default values within each class. This simplifies the instantiation process and ensures consistency in type initialization. * Refactor news provider tests and optimize cache sorting. Updated unit tests to correct async handling and removed unnecessary parameters from provider constructors. Optimized news cache sorting by ensuring it maintains the most recent entries up to the max cache size. * Set correct date in VkNewsProvider using Unix timestamp Updated the `Date` field to use `FromUnixTimeSeconds(x.Date)` instead of `DateTimeOffset.Now`. This ensures the date reflects the actual timestamp from the source data rather than the current system time. * Add GmlManager integration for news providers Integrates GmlManager into news providers, allowing dynamic updates and management of related settings. Adjusted constructors and methods across relevant classes to support GmlManager injection and usage for improved configurability. * Refactor news cache management in NewsListenerProvider. Replaces LinkedList with List for _newsCache to improve sorting and trimming logic. Simplifies and optimizes cache updates, removing redundant steps and ensuring consistent behavior when handling news items. * Use SHA1 instead of SHA256 for file hashing. Replaced SHA256Managed with SHA1.Create in ProfileProcedures and GameDownloaderProcedures for file hash calculation. This ensures consistent algorithm usage and simplifies the implementation. * Add folder whitelisting functionality to profile creation Enhanced the profile creation process by introducing folder whitelisting. Added support for specifying predefined folders like "saves" and "logs" through `AddFolderToWhiteList`. Extended `LocalFolderInfo` to include a constructor for easier initialization with a path. * Add mod management methods to IGameProfile interface Introduced methods for adding, removing, and managing mods within the game profile, including support for optional mods. These changes enhance mod handling capabilities and enable better customization options for game profiles. * Add priority field to game profiles Introduced a 'priority' field in game profiles and updated related interfaces, models, and procedures to accommodate it. This allows the handling and ordering of profiles based on their priority, enhancing profile management functionality. * Organize target frameworks in project files Reordered target frameworks in Gml.Core and Gml.Common project files for consistency. This ensures a standardized order, improving project readability and maintainability. * Adjust target frameworks in Gml.Core.Interfaces project file. Removed support for net9.0 from the TargetFrameworks property. This change ensures compatibility with the intended frameworks and simplifies the build configuration. * Refactor CreateProcess method and add native files support Reformatted the CreateProcess method for better readability and maintainability. Introduced AddNatives method to include native files from the "natives" directory, enhancing file retrieval functionality. * Update submodule CmlLib.ExtendedCore --------- Co-authored-by: teslyuk.a.p <tcop29711@gmail.com> Co-authored-by: Terentev A. A. <terentev.a.a@recloud.tech>
Update to v1.0.6 (#78)
Updated exception logging to include meaningful messages for better context in error output. Additionally, wrapped specific test cases in DEBUG conditional directives to ensure they are only executed in the debug environment.
Enclosed the GetOnline unit test within a DEBUG preprocessor directive. This ensures the test is only included in debug builds, improving build configurations and test isolation in non-debug environments.
Replaced IEnumerable<T> with ICollection<T> in GetUsersAsync for better collection handling. Introduced new tests for user, auth, and restore procedures, ensuring robust coverage. Enabled NamelessMC auth service and removed unused HttpClientFactory reference.
Introduced tests covering file hash calculation and OS type string conversions. Validates proper functionality for expected inputs and ensures appropriate exceptions are thrown for invalid cases.
Introduce tests to verify the deserialization of TextureReadDto using Newtonsoft.Json. Cover scenarios for valid JSON input and empty JSON input to ensure expected object structures and default property values are handled correctly.
Introduces tests to validate the ToModrinthString and ToCurseForge methods for all supported GameLoader types. Ensures correct behavior and exception handling for invalid inputs.
Refactored `Empty` user property to be read-only and updated its default values. Revised the corresponding test to validate the properties of the `Empty` user instead of testing invalid tokens.
Previously, the `.env` file for `tests/GmlCore.Tests` was not ignored, which could lead to accidental commits of sensitive or environment-specific data. This update ensures the file is now properly ignored.
Marked `StorageSettings` as nullable in `GmlSettings` to improve null safety. Updated tests to handle nullable `StorageSettings` and added `.env` file support for environment variable configuration. Moved `LauncherVersion` to a dedicated file for better organization.
Simplified the ReplaceParameterVisitor class by replacing private fields and explicit constructor with a record-style constructor. This improves readability and reduces boilerplate code.
Introduce tests to verify ReplaceParameterVisitor correctly replaces specified parameters. Includes cases for replacing the target parameter and returning other parameters unchanged.
Created a CI workflow to automate building, testing, and validating the Docker setup on pushes to the main branch or version tags. Integrated it into the solution file to ensure visibility and maintain consistency.
Adjusted the test path in the Docker publish workflow to point to the correct project file, ensuring the appropriate tests are executed. This fixes potential issues with incorrect test execution during the CI pipeline.
The FORGE_TOKEN secret is now passed to the test job in the Docker package publish workflow. This ensures the tests have the required authentication or configuration to run successfully.
Implemented `CancellationTokenSource` with a 1-second timeout for Minecraft ping tests to improve reliability and control over test execution. Added handling for `OperationCanceledException` to log when a ping operation is canceled. This ensures tests handle timeout scenarios gracefully.
Replaced all occurrences of `GamerVIILauncher` with `GmlServer` to reflect the updated naming. Additionally, added proper disposal of a log subscription in `UnitTests` to prevent resource leaks.
Renamed the test action to specify Gml.Core and adjusted the test path to point to the correct project file. Ensures the workflow is accurately testing the intended project.
The Build_launcher test is now wrapped in a DEBUG compiler directive to ensure it runs only in debug mode. This change prevents the test from executing in production, adhering to testing constraints.
Added `ToString` and `Equals` overrides to `LocalFolderInfo` to enable object comparisons and improve debugging clarity. Simplified `RemoveWhiteListFolderIfNotExists` by replacing manual path checks with `Contains` and `Remove` calls, leveraging the updated equality logic.
Introduced `GetProfileFiles(string directory)` to retrieve specific profile file information, enhancing flexibility in file access. Refactored `LocalFileInfo` to include equality checks and improved data comparison. Optimized `SystemHelper` with modern switch expressions for better readability and maintainability.
Refactored and organized server ping tests into a separate file, `ServersPingTest.cs`, for better modularity and maintainability. Removed duplicate test cases from `UnitTests.cs` to reduce redundancy.
Extended the `AuthType` enum and `ServicesIntegrationProcedures` to include WebMCR. This enables integration with WebMCR as a new authentication option.
Introduce a new method, SolveAllAsync, in IBugTrackerProcedures and its implementation. This method delegates the task of clearing all bugs to the storage layer via ClearBugsAsync.
Replaced `Array.Empty<INewsData>()` with a concise array literal `[]`. This refactor improves code readability and aligns with modern C# practices.
Wrapped HTTP requests in a try-catch block to handle potential exceptions. Added error capturing using the bug tracker for improved diagnostics. Ensured graceful handling by returning an empty list when an error occurs.
Added specific handling for HttpRequestException with a 404 error in the GetClockUrl method. This ensures 404 errors are logged and an empty string is returned, improving stability and error clarity. Other exceptions are still captured by the bug tracker.
Added a specific catch block to handle HttpRequestException with a 404 status, logging the exception and returning an empty string. This prevents unhandled exceptions and ensures better error handling for missing resources.
Introduced a new console sample project (`Gml.Core.Sample.Console`) to demonstrate basic usage of the Gml.Core library. Added detailed README documentation, including setup instructions, feature overview, and example code, to guide users in integrating and utilizing the library effectively.
Include a visual representation at the top of the README for enhanced branding and project identification. This improves first impressions and makes the project more visually appealing to contributors and users.
GamerVII-NET
added a commit
that referenced
this pull request
May 7, 2025
Merge pull request #80 from Gml-Launcher/develop
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.
No description provided.