Skip to content

feat: add HasAttribute and DoesNotHaveAttribute methods for IDirectoryInfo extensions#150

Merged
vbreuss merged 2 commits into
mainfrom
topic/add-hasattribute-for-directoryinfo
May 19, 2026
Merged

feat: add HasAttribute and DoesNotHaveAttribute methods for IDirectoryInfo extensions#150
vbreuss merged 2 commits into
mainfrom
topic/add-hasattribute-for-directoryinfo

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 19, 2026

This pull request introduces support for verifying file attributes on directories in the aweXpect.Testably library, aligning the API for IDirectoryInfo with the existing support for IFileInfo. It also refactors attribute constraint logic for better code reuse, and adds comprehensive tests for the new functionality.

New Features:

  • Added HasAttribute and DoesNotHaveAttribute extension methods for IDirectoryInfo, allowing assertions on directory attributes in a fluent style.
  • Updated the public API documentation to reflect the new methods for IDirectoryInfo.

Refactoring and Code Reuse:

  • Moved the attribute constraint logic into a generic FileSystemConstraints.HasAttributeConstraint<TInfo> class, now used by both file and directory attribute assertions. This removes duplicate code and ensures consistent behavior.

Testing:

  • Added unit tests for the new HasAttribute and DoesNotHaveAttribute methods on IDirectoryInfo, covering both success and failure scenarios as well as argument validation.

@vbreuss vbreuss self-assigned this May 19, 2026
Copilot AI review requested due to automatic review settings May 19, 2026 11:59
@vbreuss vbreuss added the enhancement New feature or request label May 19, 2026
@vbreuss vbreuss enabled auto-merge (squash) May 19, 2026 11:59
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

Adds HasAttribute and DoesNotHaveAttribute assertions for IDirectoryInfo, sharing the existing file-system attribute constraint logic with IFileInfo.

Changes:

  • Introduces directory attribute assertion extensions.
  • Refactors the file attribute constraint into shared file-system helper code.
  • Adds unit and API snapshot coverage for the new directory APIs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Source/aweXpect.Testably/DirectoryInfoExtensions.HasAttribute.cs Adds public directory attribute assertion methods.
Source/aweXpect.Testably/FileInfoExtensions.HasAttribute.cs Reuses the shared attribute constraint for file assertions.
Source/aweXpect.Testably/Helpers/FileSystemConstraints.cs Adds generic HasAttributeConstraint<TInfo> for file-system info types.
Tests/aweXpect.Testably.Tests/DirectoryInfo.HasAttribute.Tests.cs Covers successful, failing, and invalid-argument cases for HasAttribute.
Tests/aweXpect.Testably.Tests/DirectoryInfo.DoesNotHaveAttribute.Tests.cs Covers successful, failing, missing-directory, and invalid-argument cases for DoesNotHaveAttribute.
Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_netstandard2.0.txt Updates public API baseline for netstandard2.0.
Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net8.0.txt Updates public API baseline for net8.0.
Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net10.0.txt Updates public API baseline for net10.0.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Test Results

    7 files  ± 0      7 suites  ±0   49s ⏱️ +6s
  700 tests + 7    699 ✅ + 7  1 💤 ±0  0 ❌ ±0 
4 162 runs  +42  4 161 ✅ +42  1 💤 ±0  0 ❌ ±0 

Results for commit 8613a16. ± Comparison against base commit fb6937a.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

👽 Mutation Results

Mutation testing badge

aweXpect.Testably

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
DirectoryInfoExtensions.HasAttribute.cs 66.67% 4 2 0 0 4 0 4 2 10
FileInfoExtensions.HasAttribute.cs 66.67% 4 2 0 0 4 0 4 2 10
Helpers\FileSystemConstraints.cs 78.02% 71 7 0 13 26 65 71 20 182

The final mutation score is 76.70%

Coverage Thresholds: high:80 low:60 break:0

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

🚀 Benchmark Results

Details

BenchmarkDotNet v0.15.8, Linux Ubuntu 24.04.4 LTS (Noble Numbat)
AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 10.0.300
[Host] : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v4
DefaultJob : .NET 10.0.8 (10.0.8, 10.0.826.23019), X64 RyuJIT x86-64-v4

Method Mean Error StdDev Gen0 Gen1 Allocated
Dummy_aweXpect 4.329 μs 0.0840 μs 0.1177 μs 0.4349 0.0916 7.31 KB

…tests now use only attributes intrinsic to a freshly created directory:

- "is present" case → FileAttributes.Directory (always set on directories, all platforms).
- "is absent" case → FileAttributes.ReadOnly (never auto-set, all platforms).
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit bd1f6d8 into main May 19, 2026
12 checks passed
@vbreuss vbreuss deleted the topic/add-hasattribute-for-directoryinfo branch May 19, 2026 12:15
@github-actions
Copy link
Copy Markdown

This is addressed in release v0.15.0.

@github-actions github-actions Bot added the state: released The issue is released label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants