Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ The goal is to keep package structure, CI, versioning, tests, documentation, and
## Coding rules

- Preserve existing naming.
- Do not introduce expression-bodied method declarations.
- Prefer explicit, readable code over short clever code.
- Public APIs must include XML documentation written in English.
- Avoid breaking public API changes unless explicitly requested.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void QueryableWhere_FiltersBySpecificationExpression()
Specification<TestItem> specification = SpecificationFactory.Create<TestItem>(
item => item.Category == "target");

TestItem[] result = query.Where(specification).ToArray();
TestItem[] result = [.. query.Where(specification)];

result.Should().HaveCount(2);
result.Select(item => item.Value).Should().Equal(1, 3);
Expand Down Expand Up @@ -164,16 +164,16 @@ public void QueryableWhere_WhenArgumentsAreNull_ThrowsArgumentNullException()
[Fact(DisplayName = "Enumerable Where filters by specification predicate")]
public void EnumerableWhere_FiltersBySpecificationPredicate()
{
IEnumerable<TestItem> source = new[]
{
IEnumerable<TestItem> source =
[
CreateItem(1, category: "target"),
CreateItem(2, category: "other"),
CreateItem(3, category: "target")
};
];
Specification<TestItem> specification = SpecificationFactory.Create<TestItem>(
item => item.Category == "target");

TestItem[] result = source.Where(specification).ToArray();
TestItem[] result = [.. source.Where(specification)];

result.Should().HaveCount(2);
result.Select(item => item.Value).Should().Equal(1, 3);
Expand All @@ -182,7 +182,7 @@ public void EnumerableWhere_FiltersBySpecificationPredicate()
[Fact(DisplayName = "Enumerable Where throws when arguments are null")]
public void EnumerableWhere_WhenArgumentsAreNull_ThrowsArgumentNullException()
{
IEnumerable<TestItem> source = Array.Empty<TestItem>();
IEnumerable<TestItem> source = [];
Specification<TestItem> specification = SpecificationFactory.All<TestItem>();

Action nullSourceAct = () => SpecificationQueryableExtensions.Where(
Expand All @@ -208,22 +208,15 @@ private static TestItem CreateItem(
return new TestItem(value, category, tags);
}

private sealed class TestItem
private sealed class TestItem(
int value,
string category,
IReadOnlyCollection<string> tags)
{
public TestItem(
int value,
string category,
IReadOnlyCollection<string> tags)
{
Value = value;
Category = category;
Tags = tags;
}

public int Value { get; }
public int Value { get; } = value;

public string Category { get; }
public string Category { get; } = category;

public IReadOnlyCollection<string> Tags { get; }
public IReadOnlyCollection<string> Tags { get; } = tags;
}
}