From b924c4e126eb50a193afbf44b4dd0d098b0efc57 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Fri, 13 Nov 2026 11:02:42 +0000 Subject: [PATCH 1/2] Add Vintage Wine kind, name mapping, maturing rule and README line --- README.md | 7 ++++++- src/Core/ProposedCode/Domain/ItemKind.cs | 6 +++++- src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs | 11 ++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d742a9..14ba558 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,12 @@ update to our system: - "Conjured" items degrade in Quality twice as fast as normal items +We have also started stocking a new product that matures with age. This +requires another update to our system: + +- "Vintage Wine" (alias "Wine") increases in Quality by 1 each day, but +once the SellIn date has passed it loses 2 Quality per day instead + Feel free to make any changes to the UpdateQuality method and add any new code as long as everything still works correctly. However, do not alter the Item class or Items property as those belong to the goblin @@ -59,4 +65,3 @@ method and Items property static if you like, we'll cover for you). Just for clarification, an item can never have its Quality increase above 50, however "Sulfuras" is a legendary item and as such its Quality is 80 and it never alters. - diff --git a/src/Core/ProposedCode/Domain/ItemKind.cs b/src/Core/ProposedCode/Domain/ItemKind.cs index 199f351..b748eb7 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,7 +31,9 @@ public static ItemKind FromName(string itemName) "Conjured Mana Cake" => new Conjured(), "Conjured" => new Conjured(), "Sulfuras, Hand of Ragnaros" => new Sulfuras(), + "Vintage Wine" => new VintageWine(), + "Wine" => new VintageWine(), _ => new Standard(), }; } -} \ No newline at end of file +} diff --git a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs index 0221621..0210df4 100644 --- a/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs +++ b/src/Core/ProposedCode/Domain/ItemMaturingPolicy.cs @@ -15,6 +15,7 @@ public ItemState Mature(ItemKind kind, ItemState state) ItemKind.AgedBrie => this.MatureAgedBrie(state), ItemKind.Backstage => this.MatureBackstage(state), ItemKind.Conjured => this.MatureConjured(state), + ItemKind.VintageWine => this.MatureVintageWine(state), ItemKind.Sulfuras => state, _ => this.MatureStandard(state), }; @@ -77,4 +78,12 @@ private ItemState MatureConjured(ItemState state) return new(newQuality, newSellIn); } -} \ No newline at end of file + + private ItemState MatureVintageWine(ItemState state) + { + var newSellIn = state.SellIn.NextDay(); + var newQuality = newSellIn.IsExpired ? state.Quality.Decrease(2) : state.Quality.Increase(); + + return new(newQuality, newSellIn); + } +} From 82474d8e08bc73e9d53c71d050ff39e4bf574296 Mon Sep 17 00:00:00 2001 From: agentic-dev agent Date: Fri, 13 Nov 2026 11:02:45 +0000 Subject: [PATCH 2/2] Add tests for Vintage Wine kind, policy and service --- .../ProposedCode/Domain/ItemKindTests.cs | 4 +++- .../Domain/ItemMaturingPolicyTests.cs | 23 ++++++++++++++++++- .../ItemMaturationServiceTests.cs | 6 ++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs index 040e12d..a0d469f 100644 --- a/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs +++ b/tests/Core.Tests/ProposedCode/Domain/ItemKindTests.cs @@ -19,10 +19,12 @@ public class ItemKindTests [InlineData("Conjured", typeof(ItemKind.Conjured))] [InlineData("Sulfuras, Hand of Ragnaros", typeof(ItemKind.Sulfuras))] [InlineData("Elixir of the Mongoose", typeof(ItemKind.Standard))] + [InlineData("Vintage Wine", typeof(ItemKind.VintageWine))] + [InlineData("Wine", typeof(ItemKind.VintageWine))] public void FromName_MapsNamesToExpectedKinds(string itemName, Type expectedType) { var result = ItemKind.FromName(itemName); 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..f61a084 100644 --- a/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs +++ b/tests/Core.Tests/ProposedCode/Domain/ItemMaturingPolicyTests.cs @@ -80,6 +80,27 @@ public void Mature_WhenKindIsConjured_FollowsExpectedRules(int quality, int sell result.SellIn.Value.Should().Be(expectedSellIn); } + [Theory] + [InlineData(10, 5, 11, 4)] + [InlineData(10, 1, 11, 0)] + [InlineData(10, 0, 8, -1)] + [InlineData(10, -1, 8, -2)] + [InlineData(0, 5, 1, 4)] + [InlineData(0, 0, 0, -1)] + [InlineData(1, 0, 0, -1)] + [InlineData(50, 5, 50, 4)] + [InlineData(49, 5, 50, 4)] + [InlineData(50, 0, 48, -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 +110,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..1e51d06 100644 --- a/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs +++ b/tests/Core.Tests/ProposedCode/ItemMaturationServiceTests.cs @@ -20,6 +20,10 @@ 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, 5, 11, 4)] + [InlineData("Wine", 10, 5, 11, 4)] + [InlineData("Vintage Wine", 10, 0, 8, -1)] + [InlineData("Wine", 10, 0, 8, -1)] public void Mature_UsesExpectedRulesForResolvedItemKinds(string name, int quality, int sellIn, int expectedQuality, int expectedSellIn) { var service = new ItemMaturationService(); @@ -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 +}