refactor: simplify file existence and content checks in test cases#1018
Conversation
There was a problem hiding this comment.
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.Testablyfrom0.13.0to0.14.0via 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. |
Test Results 102 files ±0 102 suites ±0 2h 23m 13s ⏱️ + 1m 19s 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.This pull request removes 12552 skipped tests and adds 12552 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|



This pull request updates the
aweXpect.Testablypackage 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:
aweXpect.TestablyNuGet package from version 0.13.0 to 0.14.0 inDirectory.Packages.props.Test assertion refactoring:
General assertion improvements:
await That(FileSystem.File.Exists(path)).IsTrue();andawait That(FileSystem.File.ReadAllText(path)).IsEqualTo(content);with the more fluentawait That(FileSystem).HasFile(path).WithContent(content);in all relevant test cases for file content validation.Read-only file assertions:
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.