From 1b0959f5e05c8eb507add47df7a5e3b9e2f67c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Sat, 29 Aug 2026 17:04:35 +0400 Subject: [PATCH 1/2] fix: modernize specification tests --- .../SpecificationPatternTests.cs | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/tests/PANiXiDA.Core.SpecificationPattern.UnitTests/SpecificationPatternTests.cs b/tests/PANiXiDA.Core.SpecificationPattern.UnitTests/SpecificationPatternTests.cs index 45ece21..b695e7e 100644 --- a/tests/PANiXiDA.Core.SpecificationPattern.UnitTests/SpecificationPatternTests.cs +++ b/tests/PANiXiDA.Core.SpecificationPattern.UnitTests/SpecificationPatternTests.cs @@ -134,7 +134,7 @@ public void QueryableWhere_FiltersBySpecificationExpression() Specification specification = SpecificationFactory.Create( 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); @@ -164,16 +164,16 @@ public void QueryableWhere_WhenArgumentsAreNull_ThrowsArgumentNullException() [Fact(DisplayName = "Enumerable Where filters by specification predicate")] public void EnumerableWhere_FiltersBySpecificationPredicate() { - IEnumerable source = new[] - { + IEnumerable source = + [ CreateItem(1, category: "target"), CreateItem(2, category: "other"), CreateItem(3, category: "target") - }; + ]; Specification specification = SpecificationFactory.Create( 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); @@ -182,7 +182,7 @@ public void EnumerableWhere_FiltersBySpecificationPredicate() [Fact(DisplayName = "Enumerable Where throws when arguments are null")] public void EnumerableWhere_WhenArgumentsAreNull_ThrowsArgumentNullException() { - IEnumerable source = Array.Empty(); + IEnumerable source = []; Specification specification = SpecificationFactory.All(); Action nullSourceAct = () => SpecificationQueryableExtensions.Where( @@ -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 tags) { - public TestItem( - int value, - string category, - IReadOnlyCollection 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 Tags { get; } + public IReadOnlyCollection Tags { get; } = tags; } } From e2090c9e54fdd7b90a917662c851d50bca99f7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Sat, 29 Aug 2026 17:57:55 +0400 Subject: [PATCH 2/2] docs: allow expression-bodied methods --- AGENTS.md | 1 - 1 file changed, 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 7776dd9..bba968e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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.