🧪 [Add unit tests for ThemeService]#102
Conversation
- Extracted WPF specific static calls (Application.Current.Dispatcher.Invoke and Application.Current.Resources modification) into injectable delegates in `ThemeService.cs`. - Used an internal constructor to allow test projects to inject mock delegates without requiring a full WPF application context. - Added comprehensive unit tests in `ThemeServiceTests.cs` to verify that setting Light and Dark themes invokes the UI dispatcher and attempts to apply the correct URI string.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…uring tests. - Changed `Action<Uri>` to `Action<string>` in `ThemeService` constructor. - The `pack://` scheme is not registered by default in a pure .NET test runner context, leading to `UriFormatException`. Deferring `Uri` creation to the actual default implementation inside WPF fixes this. - Updated assertions in `ThemeServiceTests.cs` to verify the exact string passed to the delegate.
…uring tests. - Changed `Action<Uri>` to `Action<string>` in `ThemeService` constructor. - The `pack://` scheme is not registered by default in a pure .NET test runner context, leading to `UriFormatException`. Deferring `Uri` creation to the actual default implementation inside WPF fixes this. - Updated assertions in `ThemeServiceTests.cs` to verify the exact string passed to the delegate.
🎯 What: The
ThemeServicewas tightly coupled to WPF singletons (Application.Current.DispatcherandApplication.Current.Resources), making it untestable in standard xUnit runners outside of a WPF application host.📊 Coverage: Unit tests now cover both branches of
SetTheme(bool isDark), verifying that a dark theme maps toDarkTheme.xamland a light theme maps toLightTheme.xaml, and that the application attempts to execute this mapping on the UI thread.✨ Result: The test coverage for
ThemeServicewent from 0% to fully testing the core path logic. It allows tests to run without raisingNullReferenceExceptions onApplication.Current.PR created automatically by Jules for task 7024160738990594637 started by @Avicennasis