Skip to content

Exclude picker classes from coverage (untestable OS shell dialogs)#30

Open
Kumara-Krishnan wants to merge 2 commits intomainfrom
fix-coverage-issues
Open

Exclude picker classes from coverage (untestable OS shell dialogs)#30
Kumara-Krishnan wants to merge 2 commits intomainfrom
fix-coverage-issues

Conversation

@Kumara-Krishnan
Copy link
Copy Markdown
Collaborator

No description provided.

Coverage Fix and others added 2 commits March 1, 2026 10:19
- Change test project target from net10.0 to net10.0-windows10.0.26100.0
  so WinUI implementation files (handlers, models, extensions) compile in tests
- Add session-level setup to initialize FileSystemProvider with real WinUI
  services via FileSystemProvider.Initialize()
- Replace mock-based extension method unit tests with WinUI argument guard
  tests that verify non-WinUI objects throw ArgumentException
- Rewrite integration tests to exercise real WinUI adapters through
  FileSystemProvider: WinUIFolderHandler, WinUIFileHandler, WinUIFile,
  WinUIFolder, FileExtensions, FolderExtensions, AsIFile/AsIFolder
- Remove incorrect WinUI source exclusion from codecoverage.config
- Update CI artifact path to net10.0-windows10.0.26100.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WinUIFileOpenPicker, WinUIFileSavePicker, WinUIFolderPicker and WindowUtil
open interactive OS shell dialogs that require a live window handle and user
input - they cannot be exercised in an automated test runner regardless of
whether the project targets WinUI or not.

Add [ExcludeFromCodeCoverage] to all four classes so coverage reflects only
the code that is actually testable. Line rate: 72.5% -> 89%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 1, 2026

Code Coverage

Package Line Rate Branch Rate Complexity Health
Cyclotron.FileSystemAdapter 90% 67% 124
Cyclotron.Telemetry 91% 61% 25
Cyclotron.Utilities 100% 100% 26
Summary 91% (500 / 548) 71% (109 / 153) 175

@Kumara-Krishnan
Copy link
Copy Markdown
Collaborator Author

@copilot review the new integration tests for winui. It only tests for argument null and not other cases. Use test specialist agent if you have to write tests

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

@Kumara-Krishnan I've opened a new pull request, #31, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Cyclotron’s FileSystemAdapter WinUI coverage/testing approach by excluding interactive picker/window-dependent code from coverage while shifting the test project to a Windows WinUI-capable target so WinUI handlers/extensions can be exercised.

Changes:

  • Exclude WinUI picker + window helper classes from code coverage via [ExcludeFromCodeCoverage].
  • Move Cyclotron.Tests to net10.0-windows10.0.26100.0 and add a TestSession initializer to call FileSystemProvider.Initialize().
  • Replace/expand FileSystemAdapter unit/integration tests to validate WinUI handlers, WinUI models/extensions, and argument guards; update CI artifact path accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Cyclotron.Tests/Unit/FileSystemAdapter/FileSystemAdapterTests.cs Updates singleton service-resolution expectations and adds WinUI argument-guard + constants tests.
Cyclotron.Tests/TestHelpers/FileSystemAdapterSetup.cs Adds session-level initialization of FileSystemProvider for all tests.
Cyclotron.Tests/Integration/FileSystemAdapter/FileSystemAdapterIntegrationTests.cs Reworks integration coverage toward WinUI handler/model/extension behaviors using real WinUI services.
Cyclotron.Tests/Cyclotron.Tests.csproj Targets a Windows-specific TFM to enable WinUI types in tests.
Cyclotron.FileSystemAdapter/WinUI/Pickers/WindowUtil.cs Excludes Win32-window-dependent utility from coverage.
Cyclotron.FileSystemAdapter/WinUI/Pickers/WinUIFolderPicker.cs Excludes interactive folder picker from coverage.
Cyclotron.FileSystemAdapter/WinUI/Pickers/WinUIFileSavePicker.cs Excludes interactive save picker from coverage.
Cyclotron.FileSystemAdapter/WinUI/Pickers/WinUIFileOpenPicker.cs Excludes interactive open picker from coverage.
.github/workflows/test.yml Updates coverage artifact path to match the new test TFM output folder.

Comment on lines +8 to +14
public class FileSystemAdapterSetup
{
[Before(TestSession)]
public static void InitializeFileSystemProvider()
{
FileSystemProvider.Initialize();
}
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a global TestSession side effect (initializing a process-wide singleton) that other tests now implicitly depend on. To reduce ordering/coupling risks, consider initializing FileSystemProvider in the specific test classes that need it (e.g., in [Before(Test)]) or refactoring FileSystemProvider so it can be safely re-initialized/reset for tests.

Copilot uses AI. Check for mistakes.
Comment on lines 610 to +627
[Test]
public void GetService_ThrowsInvalidOperationException_WhenServiceProviderIsNull()
public void GetService_ReturnsService_WhenInitialized()
{
var instance = FileSystemProvider.Instance;

var act = () => instance.GetService<IFileHandler>();
var result = instance.GetService<IFileHandler>();

act.Should().Throw<InvalidOperationException>();
result.Should().NotBeNull();
}

[Test]
public void GetRequiredService_ThrowsInvalidOperationException_WhenServiceProviderIsNull()
public void GetRequiredService_ReturnsService_WhenInitialized()
{
var instance = FileSystemProvider.Instance;

var act = () => instance.GetRequiredService<IFileHandler>();
var result = instance.GetRequiredService<IFolderHandler>();

act.Should().Throw<InvalidOperationException>();
result.Should().NotBeNull();
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests rely on FileSystemProvider having been initialized elsewhere (via the new TestSession setup). To keep the unit test class self-contained and avoid hidden ordering dependencies, initialize the provider explicitly within this test class (or within these specific tests) before accessing FileSystemProvider.Instance.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to +26
[Before(Test)]
public void Setup()
public async Task Setup()
{
_fixture = new TempFileSystemFixture();
_folderHandler = FileSystemProvider.Instance.GetRequiredService<IFolderHandler>();
_fileHandler = FileSystemProvider.Instance.GetRequiredService<IFileHandler>();
_rootFolder = await _folderHandler.GetFolderFromPathAsync(_fixture.RootPath);
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup() assumes FileSystemProvider.Instance is already initialized by the TestSession hook. If that hook is skipped/misconfigured, failures will be confusing and cascade across the suite. Consider either calling FileSystemProvider.Initialize() here (idempotently) or asserting initialization with a clearer failure message before resolving handlers.

Copilot uses AI. Check for mistakes.
with:
name: coverage-report
path: Cyclotron.Tests/bin/Release/net10.0/TestResults/coverage.cobertura.xml
path: Cyclotron.Tests/bin/Release/net10.0-windows10.0.26100.0/TestResults/coverage.cobertura.xml
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coverage artifact path is hard-coded to a specific TFM folder name. This will break the workflow again if the test TFM changes (or if multi-targeting is introduced). Consider using a glob (e.g., Cyclotron.Tests/bin/Release/**/TestResults/coverage.cobertura.xml) or emitting the actual coverage path from the test step and reusing it for upload.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +5
<TargetFramework>net10.0-windows10.0.26100.0</TargetFramework>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title suggests the change is limited to excluding picker classes from coverage, but this PR also changes the test target framework to a Windows-specific TFM and adds/rewrites substantial WinUI-focused unit/integration tests. Consider updating the PR title/description to reflect the expanded scope, or splitting the testing/TFM changes into a separate PR to keep review and rollback risk smaller.

Copilot uses AI. Check for mistakes.
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.

3 participants