From ef4438957539b606345030343418d25a8f177843 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Tue, 10 Nov 2026 11:39:39 +0000 Subject: [PATCH 1/2] Add Vintage Wine item kind and maturing rule --- src/Core/ProposedCode/Domain/ItemKind.cs | 4 ++++ src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Core/ProposedCode/Domain/ItemKind.cs b/src/Core/ProposedCode/Domain/ItemKind.cs index 199f351..9feeeb8 100644 --- a/src/Core/ProposedCode/Domain/ItemKind.cs +++ b/src/Core/ProposedCode/Domain/ItemKind.cs @@ -18,6 +18,8 @@ public sealed record Conjured : ItemKind; public sealed record Sulfuras : ItemKind; + public sealed record VintageWine : ItemKind; + public static ItemKind FromName(string itemName) { return itemName switch @@ -29,6 +31,8 @@ public static ItemKind FromName(string itemName) "Conjured Mana Cake" => new Conjured(), "Conjured" => new Conjured(), "Sulfuras, Hand of Ragnaros" => new Sulfuras(), + "Vintage Wine" => new VintageWine(), + "VintageWine" => new VintageWine(), _ => new Standard(), }; } diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 0221621..f57f4df 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -16,6 +16,7 @@ public ItemState Mature(ItemKind kind, ItemState state) ItemKind.Backstage => this.MatureBackstage(state), ItemKind.Conjured => this.MatureConjured(state), ItemKind.Sulfuras => state, + ItemKind.VintageWine => this.MatureVintageWine(state), _ => this.MatureStandard(state), }; } @@ -77,4 +78,17 @@ private ItemState MatureConjured(ItemState state) return new(newQuality, newSellIn); } + + private ItemState MatureVintageWine(ItemState state) + { + var newQuality = state.Quality.Increase(); + var newSellIn = state.SellIn.NextDay(); + + if (newSellIn.IsExpired) + { + newQuality = newQuality.Increase(2); + } + + return new(newQuality, newSellIn); + } } \ No newline at end of file From 4ce57a53e95a622d746e609705029994715f0c3b Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Tue, 10 Nov 2026 11:39:48 +0000 Subject: [PATCH 2/2] Add tests for Vintage Wine product --- .../ProposedCode/Domain/ItemKindTests.cs | 4 +++- .../Domain/ItemMaturingPolicyTests.cs | 20 ++++++++++++++++++- .../ItemMaturationServiceTests.cs | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs index 040e12d..18023c9 100644 --- a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs +++ b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs @@ -18,6 +18,8 @@ public class ItemKindTests [InlineData("Conjured Mana Cake", typeof(ItemKind.Conjured))] [InlineData("Conjured", typeof(ItemKind.Conjured))] [InlineData("Sulfuras, Hand of Ragnaros", typeof(ItemKind.Sulfuras))] + [InlineData("Vintage Wine", typeof(ItemKind.VintageWine))] + [InlineData("VintageWine", typeof(ItemKind.VintageWine))] [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 +} diff --git a/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs b/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs index 55d645c..0914257 100644 --- a/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs +++ b/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs @@ -80,6 +80,24 @@ public void Mature_WhenKindIsConjured_FollowsExpectedRules(int quality, int sell result.SellIn.Value.Should().Be(expectedSellIn); } + [Theory] + [InlineData(20, 4, 21, 3)] + [InlineData(20, 0, 23, -1)] + [InlineData(20, -1, 23, -2)] + [InlineData(48, 0, 50, -1)] + [InlineData(49, 5, 50, 4)] + [InlineData(50, 4, 50, 3)] + [InlineData(50, 0, 50, -1)] + public void Mature_WhenKindIsVintageWine_FollowsExpectedRules(int quality, int sellIn, int expectedQuality, int expectedSellIn) + { + var state = new ItemState(new Quality(quality), new SellIn(sellIn)); + + var result = this.policy.Mature(new ItemKind.VintageWine(), state); + + result.Quality.Value.Should().Be(expectedQuality); + result.SellIn.Value.Should().Be(expectedSellIn); + } + [Fact] public void Mature_WhenKindIsSulfuras_PreservesProvidedState() { @@ -89,4 +107,4 @@ public void Mature_WhenKindIsSulfuras_PreservesProvidedState() result.Should().Be(state); } -} \ No newline at end of file +} diff --git a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs index 4690ec6..4b1af8a 100644 --- a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs +++ b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs @@ -20,6 +20,8 @@ public class ItemMaturationServiceTests [InlineData("Conjured Mana Cake", 10, 5, 8, 4)] [InlineData("Conjured", 10, 0, 6, -1)] [InlineData("Sulfuras, Hand of Ragnaros", 80, 0, 80, 0)] + [InlineData("Vintage Wine", 10, 2, 11, 1)] + [InlineData("VintageWine", 10, 0, 13, -1)] public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int quality, int sellIn, int expectedQuality, int expectedSellIn) { var service = new ItemMaturationService(); @@ -35,4 +37,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 +}