Skip to content

🧪 [Add unit tests for ThemeService]#102

Merged
Avicennasis merged 3 commits into
mainfrom
test-theme-service-7024160738990594637
Jun 29, 2026
Merged

🧪 [Add unit tests for ThemeService]#102
Avicennasis merged 3 commits into
mainfrom
test-theme-service-7024160738990594637

Conversation

@Avicennasis

Copy link
Copy Markdown
Owner

🎯 What: The ThemeService was tightly coupled to WPF singletons (Application.Current.Dispatcher and Application.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 to DarkTheme.xaml and a light theme maps to LightTheme.xaml, and that the application attempts to execute this mapping on the UI thread.
Result: The test coverage for ThemeService went from 0% to fully testing the core path logic. It allows tests to run without raising NullReferenceExceptions on Application.Current.


PR created automatically by Jules for task 7024160738990594637 started by @Avicennasis

- 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.
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

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.
@Avicennasis Avicennasis merged commit 5cdfa36 into main Jun 29, 2026
5 checks passed
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