From 2e5547b07480ccb066c57f6a7bdecb1e7fe6748d Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 16:25:16 +0000 Subject: [PATCH 1/3] Test Conjured item maturation rules Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs index 4690ec6..8b22db3 100644 --- a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs +++ b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs @@ -13,12 +13,16 @@ public class ItemMaturationServiceTests { [Theory] [InlineData("Elixir of the Mongoose", 10, 5, 9, 4)] + [InlineData("Elixir of the Mongoose", 10, 0, 8, -1)] [InlineData("Aged Brie", 10, 2, 11, 1)] [InlineData("AgedBrie", 10, 2, 11, 1)] [InlineData("Backstage passes to a TAFKAL80ETC concert", 20, 10, 22, 9)] [InlineData("Backstage", 20, 5, 23, 4)] [InlineData("Conjured Mana Cake", 10, 5, 8, 4)] + [InlineData("Conjured Mana Cake", 10, 0, 6, -1)] [InlineData("Conjured", 10, 0, 6, -1)] + [InlineData("Conjured", 0, 0, 0, -1)] + [InlineData("Conjured", 3, 0, 0, -1)] [InlineData("Sulfuras, Hand of Ragnaros", 80, 0, 80, 0)] public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int quality, int sellIn, int expectedQuality, int expectedSellIn) { @@ -35,4 +39,4 @@ public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int qualit result.Quality.Should().Be(expectedQuality); result.SellIn.Should().Be(expectedSellIn); } -} \ No newline at end of file +} From ed7cdbb0d701a3efc46b5a932dad8cd401d077e2 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 16:25:24 +0000 Subject: [PATCH 2/3] Support Conjured-prefixed item classification Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Core/ProposedCode/Domain/ItemKind.cs | 5 ++--- tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Core/ProposedCode/Domain/ItemKind.cs b/src/Core/ProposedCode/Domain/ItemKind.cs index 199f351..7182588 100644 --- a/src/Core/ProposedCode/Domain/ItemKind.cs +++ b/src/Core/ProposedCode/Domain/ItemKind.cs @@ -26,10 +26,9 @@ public static ItemKind FromName(string itemName) "AgedBrie" => new AgedBrie(), "Backstage passes to a TAFKAL80ETC concert" => new Backstage(), "Backstage" => new Backstage(), - "Conjured Mana Cake" => new Conjured(), - "Conjured" => new Conjured(), + string name when name.StartsWith("Conjured", System.StringComparison.Ordinal) => new Conjured(), "Sulfuras, Hand of Ragnaros" => new Sulfuras(), _ => new Standard(), }; } -} \ No newline at end of file +} diff --git a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs index 040e12d..1a56d70 100644 --- a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs +++ b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs @@ -17,6 +17,8 @@ public class ItemKindTests [InlineData("Backstage", typeof(ItemKind.Backstage))] [InlineData("Conjured Mana Cake", typeof(ItemKind.Conjured))] [InlineData("Conjured", typeof(ItemKind.Conjured))] + [InlineData("Conjured Elixir of the Mongoose", typeof(ItemKind.Conjured))] + [InlineData("Conjured Something Else", typeof(ItemKind.Conjured))] [InlineData("Sulfuras, Hand of Ragnaros", typeof(ItemKind.Sulfuras))] [InlineData("Elixir of the Mongoose", typeof(ItemKind.Standard))] public void FromName_MapsNamesToExpectedKinds(string itemName, Type expectedType) @@ -25,4 +27,4 @@ public void FromName_MapsNamesToExpectedKinds(string itemName, Type expectedType result.Should().BeOfType(expectedType); } -} \ No newline at end of file +} From 032408a5ee63b61b81afdcdccaa4f4885f257f4b Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Sun, 29 Nov 2026 16:25:52 +0000 Subject: [PATCH 3/3] Add Spec Kit files for conjured-items.md --- specs/conjured-items/plan.md | 29 +++++++++++++++++++++ specs/conjured-items/spec.md | 49 +++++++++++++++++++++++++++++++++++ specs/conjured-items/tasks.md | 4 +++ 3 files changed, 82 insertions(+) create mode 100644 specs/conjured-items/plan.md create mode 100644 specs/conjured-items/spec.md create mode 100644 specs/conjured-items/tasks.md diff --git a/specs/conjured-items/plan.md b/specs/conjured-items/plan.md new file mode 100644 index 0000000..f632707 --- /dev/null +++ b/specs/conjured-items/plan.md @@ -0,0 +1,29 @@ +# Implementation plan: Conjured items + +## Technical context + +The repository uses C# on .NET 8. The proposed implementation classifies item names with `ItemKind`, applies rules through `ItemMaturingPolicy`, and enforces quality bounds in the `Quality` value object. Tests use xUnit and FluentAssertions; CI runs `dotnet test`. + +## Approach + +Extend `ItemKind.FromName` to classify any name starting with `Conjured` as `ItemKind.Conjured`, preserving the existing policy that decreases quality by two before expiry and four after expiry. Keep quality clamping in `Quality`; verify it through maturation tests. Retain regression coverage for all non-Conjured item kinds and their existing rules. + +## Files + +- `src/Core/ProposedCode/Domain/ItemKind.cs` — recognize all names with the `Conjured` prefix. +- `tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs` — cover the named example and a different Conjured-prefixed name, plus a nonmatching name. +- `tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs` — verify normal and expired Conjured quality changes, nonnegative quality, and unchanged behavior across non-Conjured item kinds. + +## Risks + +Prefix matching intentionally classifies more names as Conjured than the current exact-name cases. Sell-by expiry follows the existing `SellIn` and maturation-policy semantics. No public interfaces or migrations need to change. + +## Test plan + +Run `dotnet test tests/Core.Tests/GildedRoseKata.Core.Tests.csproj`. + +- **FR-001:** Service tests verify that “Conjured Mana Cake” and another Conjured-prefixed name lose two quality before expiry. +- **FR-002:** Service tests verify four quality lost for an expired Conjured item. +- **FR-003:** Service tests verify quality remains zero when the decrease would take it below zero. +- **FR-004:** Regression cases verify existing behavior for standard, Aged Brie, Backstage, and Sulfuras items. +- **FR-005:** The test suite includes cases for FR-001 through FR-004. \ No newline at end of file diff --git a/specs/conjured-items/spec.md b/specs/conjured-items/spec.md new file mode 100644 index 0000000..5856dfa --- /dev/null +++ b/specs/conjured-items/spec.md @@ -0,0 +1,49 @@ +# Feature specification: Conjured items +UI work: no +conjured-items.md + +## User scenarios + +**Recognize Conjured items.** An inventory manager wants items whose names start with “Conjured” to lose quality faster, so their quality reflects their special status. + +- **Given** an item whose name starts with “Conjured” and whose sell-by date has not passed, **when** the inventory is updated, **then** its quality decreases twice as fast as a normal item’s. + +**Handle expired Conjured items.** An inventory manager wants Conjured items to lose quality faster after their sell-by date, so expired stock is reflected accurately. + +- **Given** a Conjured item whose sell-by date has passed, **when** the inventory is updated, **then** its quality decreases four times as fast as a normal item’s. + +**Keep quality nonnegative.** An inventory manager wants item quality to remain valid as it decreases. + +- **Given** an item with quality that would fall below zero during an inventory update, **when** the inventory is updated, **then** its quality is zero, not negative. + +**Preserve other item behavior.** An inventory manager wants existing inventory behavior to remain reliable while Conjured items are added. + +- **Given** an item whose name does not start with “Conjured”, **when** the inventory is updated, **then** its behavior is unchanged. + +## Requirements + +- **FR-001:** The system shall decrease the quality of any item whose name starts with “Conjured” twice as fast as a normal item before its sell-by date. +- **FR-002:** The system shall decrease the quality of a Conjured item four times as fast as a normal item after its sell-by date. +- **FR-003:** The system shall never allow an item’s quality to fall below zero. +- **FR-004:** The system shall leave the existing behavior of every item whose name does not start with “Conjured” unchanged. +- **FR-005:** The project shall include tests for each requirement. + +## Success criteria + +- **SC-001:** An item named “Conjured Mana Cake” and another item with a different name starting with “Conjured” both lose quality twice as fast as a normal item before their sell-by dates. +- **SC-002:** An expired Conjured item loses quality four times as fast as a normal item. +- **SC-003:** Tests confirm that quality does not become negative. +- **SC-004:** Tests confirm that existing behavior for every non-Conjured item is unchanged. +- **SC-005:** Automated tests cover FR-001 through FR-004. + +## Acceptance criteria + +- **AC-001 (FR-001):** When an inventory update processes an item whose name starts with “Conjured” before its sell-by date, the system shall decrease its quality twice as fast as a normal item. +- **AC-002 (FR-002):** When an inventory update processes a Conjured item after its sell-by date, the system shall decrease its quality four times as fast as a normal item. +- **AC-003 (FR-003):** When an inventory update would reduce an item’s quality below zero, the system shall set its quality to zero. +- **AC-004 (FR-004):** When an inventory update processes an item whose name does not start with “Conjured”, the system shall preserve that item’s existing behavior. +- **AC-005 (FR-005):** When the project’s automated tests run, the system shall have tests that verify FR-001, FR-002, FR-003, and FR-004. + +## Out of scope + +- User interface changes. \ No newline at end of file diff --git a/specs/conjured-items/tasks.md b/specs/conjured-items/tasks.md new file mode 100644 index 0000000..1ef9930 --- /dev/null +++ b/specs/conjured-items/tasks.md @@ -0,0 +1,4 @@ +# Tasks: Conjured items +- [ ] T001 [P] Add classification tests for multiple `Conjured`-prefixed names and a nonmatching name in `tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs` (FR-001, FR-004, AC-001, AC-004, AC-005) +- [ ] T002 [P] Add maturation tests for regular and expired Conjured items, nonnegative quality, and unchanged non-Conjured behavior in `tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs` (FR-001, FR-002, FR-003, FR-004, FR-005, AC-001, AC-002, AC-003, AC-004, AC-005) +- [ ] T003 Update name classification to recognize any `Conjured` prefix in `src/Core/ProposedCode/Domain/ItemKind.cs` after T001 (FR-001, AC-001) \ No newline at end of file