refactor: modernize tests after updating aweXpect.Testably to v0.15.0#1020
Merged
vbreuss merged 6 commits intoMay 20, 2026
Merged
Conversation
Pulls in the new IFileInfo/IDirectoryInfo attribute, IDriveInfo, IFileVersionInfo, and ITimerMock expectations introduced in 0.15.0.
Replaces SemaphoreSlim + Interlocked + Volatile.Read coordination in two DisableAutoAdvance tests with the new ITimerMock.Executed() assertion from aweXpect.Testably 0.15.0. Drops 25 lines of synchronisation plumbing while preserving the exact-count verification via the ExecutionCount property. ShouldNotBeAffectedByTimeChange and DisableAutoAdvance_ShouldStart... stay as-is - they need per-tick coordination or capture the callback timestamp, which the new API does not expose.
… info Replaces assertions of the form await That(sut.Attributes).HasFlag(FileAttributes.X) with the typed extension await That(sut).HasAttribute(FileAttributes.X) (and the negated variant) introduced for IFileInfo/IDirectoryInfo in aweXpect.Testably 0.15.0. The subject becomes the file/directory itself, yielding clearer failure messages. InMemoryContainerTests is intentionally left alone - its subject is IStorageContainer, which the new extensions do not target.
Replaces property-then-IsEqualTo patterns with the typed IDriveInfo extensions introduced in 0.15.0: - That(drive.AvailableFreeSpace).IsEqualTo(x) -> That(drive).HasAvailableFreeSpace(x) - That(drive.TotalSize).IsEqualTo(x) -> That(drive).HasTotalSize(x) - That(drive.TotalFreeSpace).IsEqualTo(x) -> That(drive).HasTotalFreeSpace(x) - That(drive.VolumeLabel).IsEqualTo(x) -> That(drive).HasVolumeLabel(x) - That(drive.DriveFormat).IsEqualTo(x) -> That(drive).HasDriveFormat(x) - That(drive.DriveType).IsEqualTo(x) -> That(drive).HasDriveType(x) - That(drive.Name).IsEqualTo(x) -> That(drive).HasName(x) - That(drive.IsReady).IsTrue() -> That(drive).IsReady() Assertions that the new API does not cover (IsGreaterThan, IsNotEmpty, IsNotNull, IsNotNullOrEmpty, IsEqualTo with a runtime bool) are left unchanged.
…ably Replaces property-then-IsEqualTo patterns with typed extensions added to IFileVersionInfo in 0.15.0: - HasCompanyName, HasFileDescription, HasFileVersion, HasLanguage, HasOriginalFilename, HasProductName, HasProductVersion Properties without dedicated extensions (Comments, InternalName, LegalCopyright, LegalTrademarks, PrivateBuild, SpecialBuild, IsDebug/IsPatched/IsPreRelease/IsPrivateBuild/IsSpecialBuild, FileMajor/Minor/Build/PrivatePart, ProductMajor/Minor/Build/PrivatePart) keep the original IsEqualTo form.
Replaces
await That(drives).HasSingle()
.Matching(d => string.Equals(d.Name, driveName, StringComparison.Ordinal));
with
await That(sut).HasDrive(driveName);
introduced for IFileSystem in 0.15.0. Drive names are unique within a
file system, so HasDrive's "at least one drive with this name" is
equivalent to the prior "exactly one matching" check. The accompanying
length assertion is kept to preserve the test's count semantics.
Tests intentionally targeting an exact ordinal name form (e.g.
WithDrive_ShouldHavePathSeparatorSuffix, which verifies the trailing
separator) are left alone since HasDrive normalizes trailing slashes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adopt aweXpect.Testably 0.15.0 assertions in the test suite
Summary
aweXpect.Testablyfrom 0.14.0 to 0.15.0.ITimerMock,IFileInfo/IDirectoryInfo,IDriveInfo,IFileVersionInfo, andIFileSystemexpectations introduced in 0.15.0.Net change: -31 lines across 11 files. The biggest win is
TimerMockTests, whereTimer.Executed().Within(...)replaces aSemaphoreSlim+Interlocked.Increment+Volatile.Readcoordination pattern.Commits (one per concern, easy to review or revert individually)
chore(deps): bump aweXpect.Testably to 0.15.0Directory.Packages.propsrefactor(tests): use Timer.Executed().Within() in TimerMockTestsTimerMockTests.csrefactor(tests): use HasAttribute/DoesNotHaveAttribute on file system infoTests/Testably.Abstractions.Tests/FileSystem/...refactor(tests): use IDriveInfo expectations from aweXpect.TestablyDriveInfoMockTests.cs,MockFileSystemTests.cs,DriveInfo/Tests.cs,DriveInfoFactory/Tests.csrefactor(tests): use IFileVersionInfo expectations from aweXpect.TestablyFileVersionInfoBuilderTests.csrefactor(tests): use IFileSystem.HasDrive in MockFileSystemTestsMockFileSystemTests.csRefactor patterns
Timer callbacks (the big one)
Intentionally not refactored