Skip to content

Expand WinUI FileSystemAdapter test coverage: functional combinations and full guard coverage#31

Draft
Copilot wants to merge 4 commits into
fix-coverage-issuesfrom
copilot/sub-pr-30
Draft

Expand WinUI FileSystemAdapter test coverage: functional combinations and full guard coverage#31
Copilot wants to merge 4 commits into
fix-coverage-issuesfrom
copilot/sub-pr-30

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Tests were limited to a subset of argument-guard checks and shallow existence assertions — no content verification, no collision-option combinations, and many handler overloads were untested entirely.

Argument guard completeness (FileSystemAdapterTests.cs)

Added 18 unit tests covering every previously untested type guard:

  • WinUIFileHandler — second-argument guards for CopyAndReplaceAsync, CopyAsync, MoveAndReplaceAsync, and all three MoveAsync overloads
  • WinUIFolderHandler — all overloads and methods with no prior guard test: CreateFileAsync(+option), CreateFolderAsync(+option), DeleteAsync(+option), GetFileAsync (all-files), GetFoldersAsync, GetItemAsync, GetItemsAsync, GetParentAsync, RenameAsync(+option), TryGetItemAsync

Destination-guard tests obtain a real WinUIFile via GetFileFromPathAsync (the only way to construct the internal type) so the first guard passes and the second is the code path under test:

[Test]
public async Task WinUIFileHandler_CopyAsync_ThrowsArgumentException_WhenDestFolderNotWinUIFolder()
{
    var handler = FileSystemProvider.Instance.GetRequiredService<IFileHandler>();
    var tempPath = Path.GetTempFileName();
    try
    {
        var realSource = await handler.GetFileFromPathAsync(tempPath); // passes first guard

        var act = async () => await handler.CopyAsync(realSource, Substitute.For<IFolder>(), "file.txt", NameCollisionOption.ReplaceExisting);

        await act.Should().ThrowAsync<ArgumentException>(); // second guard fires
    }
    finally { File.Delete(tempPath); }
}

Functional integration coverage (FileSystemAdapterIntegrationTests.cs)

Added 32 integration tests across 11 new regions verifying actual behaviour and data correctness:

  • Content preservation — copy/move/replace carry byte content to destination; source absent after move
  • All collision combinations for CopyAsync, MoveAsync, RenameAsync, CreateFileAsync, CreateFolderAsyncFailIfExists throws IOException; GenerateUniqueName leaves both items on disk; ReplaceExisting overwrites content / removes old path
  • Return-value precisionPath, Name, FolderRelativeId exact values; GetItemAsync returns IFile vs IFolder correctly; GetSizeAsync returns exactly 5UL for a known 5-byte file
  • Empty folder edge casesGetFileAsync, GetFoldersAsync, GetItemsAsync return empty (not null/error)
  • Not-found errorGetItemAsync throws FileNotFoundException
  • Rename removes old path — both old-gone and new-present asserted
  • OpenAsync(AllowReadersAndWriters) and StorageDeletionOption.Default — previously untested overloads

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • az667904.vo.msecnd.net
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.102/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • vortex.data.microsoft.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.102/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ions, ReadWrite mode

Co-authored-by: Kumara-Krishnan <5687650+Kumara-Krishnan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • az667904.vo.msecnd.net
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.102/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)
  • vortex.data.microsoft.com
    • Triggering command: /usr/share/dotnet/dotnet /usr/share/dotnet/dotnet /usr/share/dotnet/sdk/10.0.102/MSBuild.dll /noautoresponse /nologo /nodemode:1 /nodeReuse:true /low:false (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Exclude picker classes from coverage due to untestable OS dialogs Expand WinUI integration tests beyond argument-guard coverage Mar 1, 2026
…ethod overloads

Co-authored-by: Kumara-Krishnan <5687650+Kumara-Krishnan@users.noreply.github.com>
Copilot AI changed the title Expand WinUI integration tests beyond argument-guard coverage Expand WinUI handler test coverage: missing overloads and second-argument guards Mar 1, 2026
…handler combinations

Co-authored-by: Kumara-Krishnan <5687650+Kumara-Krishnan@users.noreply.github.com>
Copilot AI changed the title Expand WinUI handler test coverage: missing overloads and second-argument guards Expand WinUI FileSystemAdapter test coverage: functional combinations and full guard coverage Mar 1, 2026
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.

2 participants