Skip to content

refactor: simplify file existence and content checks in test cases#1018

Merged
vbreuss merged 2 commits into
mainfrom
topic/simplify-file-existence-and-content-checks-in-test-cases
May 19, 2026
Merged

refactor: simplify file existence and content checks in test cases#1018
vbreuss merged 2 commits into
mainfrom
topic/simplify-file-existence-and-content-checks-in-test-cases

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 19, 2026

This pull request updates the aweXpect.Testably package to version 0.14.0 and refactors the test code to use new assertion methods provided by this package. The main focus is on improving the readability and expressiveness of file system assertions in tests by replacing manual file existence and content checks with fluent assertion chains.

Dependency update:

  • Upgraded the aweXpect.Testably NuGet package from version 0.13.0 to 0.14.0 in Directory.Packages.props.

Test assertion refactoring:

General assertion improvements:

  • Replaced assertions like await That(FileSystem.File.Exists(path)).IsTrue(); and await That(FileSystem.File.ReadAllText(path)).IsEqualTo(content); with the more fluent await That(FileSystem).HasFile(path).WithContent(content); in all relevant test cases for file content validation.

Read-only file assertions:

  • Updated assertions for read-only file flags to use the new fluent syntax: await That(fileSystem).HasFile(name).Which.IsReadOnly(); or .IsNotReadOnly(); depending on the test case.

These changes modernize the test code, making it more expressive and easier to maintain by leveraging the latest features of aweXpect.Testably.

@vbreuss vbreuss self-assigned this May 19, 2026
Copilot AI review requested due to automatic review settings May 19, 2026 09:38
@vbreuss vbreuss added the refactor A change or improvement without functional impact label May 19, 2026
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

This PR upgrades the aweXpect.Testably dependency and refactors the test suite to use its newer fluent file-system assertions, reducing repetitive Exists + ReadAllText/ReadAllBytes patterns and improving assertion readability across many tests.

Changes:

  • Bumped aweXpect.Testably from 0.13.0 to 0.14.0 via central package management.
  • Refactored file existence + content assertions to That(FileSystem).HasFile(path).WithContent(...) (and related fluent chains).
  • Updated read-only file assertions in initializer tests to use fluent Which.IsReadOnly() / Which.IsNotReadOnly().

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ReplaceTests.cs Refactors Replace-related file assertions to fluent HasFile(...).WithContent(...).
Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs Refactors MoveTo file assertions and adds aweXpect.Testably import.
Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTextTests.cs Uses fluent file assertions for created/replaced text.
Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CopyToTests.cs Refactors CopyTo assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AppendTextTests.cs Refactors append text assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs Uses fluent file assertions for BOM byte validation scenarios.
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesTests.cs Refactors byte write assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesAsyncTests.cs Refactors async byte write assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/ReplaceTests.cs Refactors Replace assertions using HasFile(...).WhoseContent(...) patterns.
Tests/Testably.Abstractions.Tests/FileSystem/File/MoveTests.cs Refactors Move assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTextTests.cs Uses fluent file assertions for CreateText scenarios.
Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTests.cs Refactors Create overwrite assertion to fluent file + content check.
Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs Refactors Copy assertions to fluent file + content checks (including binary clone test).
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendTextTests.cs Refactors append text assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs Refactors AppendAllText assertions (including BOM bytes) to fluent checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs Refactors AppendAllTextAsync assertions to fluent checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs Refactors AppendAllLines assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs Refactors AppendAllLinesAsync assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesTests.cs Refactors AppendAllBytes assertions to fluent file + content checks.
Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesAsyncTests.cs Refactors AppendAllBytesAsync assertions to fluent file + content checks.
Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileSystemInitializerTests.cs Refactors initializer assertions to fluent file + content/read-only checks and adds import.
Directory.Packages.props Updates aweXpect.Testably package version to 0.14.0.

Comment thread Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Test Results

    102 files  ±0      102 suites  ±0   2h 23m 13s ⏱️ + 1m 19s
112 584 tests +7   99 973 ✅ +6  12 610 💤 ±0  1 ❌ +1 
268 790 runs  ±0  232 101 ✅  - 1  36 688 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit d8a8831. ± Comparison against base commit a59239b.

This pull request removes 109737 and adds 109743 tests. Note that renamed tests count towards both.
  )
)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0e54c42c-ad28-4790-a178-1e4d48de8eaf)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(17e17eb6-be1b-486e-82fd-ad6850f56263)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1b762819-f6a3-4506-8ae8-c7c2e32aa804)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(275bdc13-2044-45f4-b219-f24811a4011a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(283267f2-e63b-40dc-8379-323d8026d4eb)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3a470203-d11e-4aee-9820-68a9adbbbb6a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(4151ab95-4dfd-4fc3-8353-b09334e5a26f)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(46c63ac6-4ddd-4ebf-b581-3e6fa613dbf5)
…
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(03d998e4-0e61-4d1c-8653-bf3470f4ebbb)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0bf4d662-566a-4d35-9231-d27623d34298)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1082bb56-9f50-42bd-bd72-05a5f11fe2e7)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(12fd0905-b088-4a3e-af25-88af3e95412f)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(238611c5-845a-4d9b-afb0-633d37db2b4e)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(23a63153-f06a-454f-b767-5b0ec8550593)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2bcb9669-92bb-4181-a42f-21dbf1c3c67d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2eb0ef0d-f0de-4e51-9798-5dfc15ea0558)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3d7fc40e-7bda-4fbe-a564-a673c6df7a5d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(4de30124-146a-4956-bd2b-b0db9694e943)
…
This pull request removes 12552 skipped tests and adds 12552 skipped tests. Note that renamed tests count towards both.
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0e54c42c-ad28-4790-a178-1e4d48de8eaf)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(17e17eb6-be1b-486e-82fd-ad6850f56263)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1b762819-f6a3-4506-8ae8-c7c2e32aa804)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(275bdc13-2044-45f4-b219-f24811a4011a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(283267f2-e63b-40dc-8379-323d8026d4eb)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3a470203-d11e-4aee-9820-68a9adbbbb6a)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(4151ab95-4dfd-4fc3-8353-b09334e5a26f)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(46c63ac6-4ddd-4ebf-b581-3e6fa613dbf5)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(57c4fd4b-ebeb-480a-9b23-ddc61acd8d43)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(656f06d0-4aee-4180-8774-15b2c86fde67)
…
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(03d998e4-0e61-4d1c-8653-bf3470f4ebbb)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(0bf4d662-566a-4d35-9231-d27623d34298)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(1082bb56-9f50-42bd-bd72-05a5f11fe2e7)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(12fd0905-b088-4a3e-af25-88af3e95412f)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(238611c5-845a-4d9b-afb0-633d37db2b4e)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(23a63153-f06a-454f-b767-5b0ec8550593)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2bcb9669-92bb-4181-a42f-21dbf1c3c67d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(2eb0ef0d-f0de-4e51-9798-5dfc15ea0558)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(3d7fc40e-7bda-4fbe-a564-a673c6df7a5d)
Testably.Abstractions.AccessControl.Tests.DirectoryInfoAclExtensionsTests ‑ SetAccessControl_ShouldNotUpdateTimes(4de30124-146a-4956-bd2b-b0db9694e943)
…

♻️ This comment has been updated with latest results.

@vbreuss vbreuss enabled auto-merge (squash) May 19, 2026 11:00
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit 85d4aec into main May 19, 2026
20 of 22 checks passed
@vbreuss vbreuss deleted the topic/simplify-file-existence-and-content-checks-in-test-cases branch May 19, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor A change or improvement without functional impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants